enum {
CONFIG, PLUGIN, MODULE,
- LOOP, PASS, STDIN,
+ LOOP, PASS, STDIN, COLOR,
// sound options
DRIVER, SRATE, NINPUT, NOUTPUT,
// pp options
vector_init(&arg->lib);
vector_init(&arg->config);
vector_add(&arg->lib, (vtype)plug_dir());
+ arg->color = COLOR_AUTO;
}
ANN void arg_release(Arg* arg) {
static void setup_options(cmdapp_t* app, cmdopt_t* opt) {
cmdapp_set(app,
- 'c', "config",
+ 'C', "config",
CMDOPT_TAKESARG, NULL,
"parse a config file", &opt[CONFIG]
);
0, NULL,
"read from stdin", &opt[STDIN]
);
+ cmdapp_set(app,
+ 'c', "color",
+ CMDOPT_TAKESARG, NULL,
+ "set colored output (never/auto/always, defaults to auto)", &opt[STDIN]
+ );
// sound options
cmdapp_set(app,
'd', "driver",
case 'm':
module_arg(&_arg->mod, option->value);
break;
- case 'c':
+ case 'C':
config_parse(arg_int, option->value);
break;
case 'l':
case '\0':
vector_add(&_arg->add, (vtype)ARG_STDIN);
break;
+ case 'c':
+ if(!strcmp(option->value, "never"))
+ _arg->color = COLOR_NEVER;
+ else if(!strcmp(option->value, "auto"))
+ _arg->color = COLOR_AUTO;
+ else if(!strcmp(option->value, "always"))
+ _arg->color = COLOR_ALWAYS;
+ // ignore error silently
+ break;
// sound options
case 's':
_arg->si->sr = (uint32_t)ARG2INT(option->value);
#include <locale.h>
#include <libintl.h>
#endif
+#include <unistd.h>
#include "gwion_util.h"
#include "gwion_ast.h"
#include "gwion_env.h"
pass_default(gwion);
arg->si = gwion->vm->bbq->si = new_soundinfo(gwion->mp);
CHECK_BB(arg_parse(gwion, arg))
+ if(arg->color == COLOR_NEVER)
+ tcol_override_color_checks(0);
+ else if(arg->color == COLOR_AUTO)
+ tcol_override_color_checks(isatty(1));
+ else if(arg->color == COLOR_ALWAYS)
+ tcol_override_color_checks(1);
return !arg->quit ? gwion_ok(gwion, arg) : GW_ERROR;
}