Add mute feature

This will make tio go fully silent and not print anything.
This commit is contained in:
Martin Lund 2022-10-22 08:59:34 +02:00
parent 784201ea2e
commit c80f833a06
3 changed files with 23 additions and 0 deletions

View file

@ -35,6 +35,7 @@ _tio()
--rs-485 \ --rs-485 \
--rs-485-config \ --rs-485-config \
--alert \ --alert \
--mute \
-v --version \ -v --version \
-h --help" -h --help"
@ -141,6 +142,10 @@ _tio()
COMPREPLY=( $(compgen -W "none bell blink" -- ${cur}) ) COMPREPLY=( $(compgen -W "none bell blink" -- ${cur}) )
return 0 return 0
;; ;;
--mute)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
-v | --version) -v | --version)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0

View file

@ -302,6 +302,17 @@ static int data_handler(void *user, const char *section, const char *name,
{ {
option.alert = alert_option_parse(value); option.alert = alert_option_parse(value);
} }
else if (!strcmp(name, "mute"))
{
if (!strcmp(value, "enable"))
{
option.mute = true;
}
else if (!strcmp(value, "disable"))
{
option.mute = false;
}
}
} }
return 0; return 0;

View file

@ -51,6 +51,7 @@ enum opt_t
OPT_RS485_CONFIG, OPT_RS485_CONFIG,
OPT_ALERT, OPT_ALERT,
OPT_COMPLETE_SUB_CONFIGS, OPT_COMPLETE_SUB_CONFIGS,
OPT_MUTE,
}; };
/* Default options */ /* Default options */
@ -127,6 +128,7 @@ void print_help(char *argv[])
printf(" --rs-485 Enable RS-485 mode\n"); printf(" --rs-485 Enable RS-485 mode\n");
printf(" --rs-485-config <config> Set RS-485 configuration\n"); printf(" --rs-485-config <config> Set RS-485 configuration\n");
printf(" --alert bell|blink|none Alert on connect/disconnect (default: none)\n"); printf(" --alert bell|blink|none Alert on connect/disconnect (default: none)\n");
printf(" --mute Mute tio\n");
printf(" -v, --version Display version\n"); printf(" -v, --version Display version\n");
printf(" -h, --help Display help\n"); printf(" -h, --help Display help\n");
printf("\n"); printf("\n");
@ -258,6 +260,7 @@ void options_parse(int argc, char *argv[])
{"rs-485", no_argument, 0, OPT_RS485 }, {"rs-485", no_argument, 0, OPT_RS485 },
{"rs-485-config", required_argument, 0, OPT_RS485_CONFIG }, {"rs-485-config", required_argument, 0, OPT_RS485_CONFIG },
{"alert", required_argument, 0, OPT_ALERT }, {"alert", required_argument, 0, OPT_ALERT },
{"mute", no_argument, 0, OPT_MUTE },
{"version", no_argument, 0, 'v' }, {"version", no_argument, 0, 'v' },
{"help", no_argument, 0, 'h' }, {"help", no_argument, 0, 'h' },
{"complete-sub-configs", no_argument, 0, OPT_COMPLETE_SUB_CONFIGS}, {"complete-sub-configs", no_argument, 0, OPT_COMPLETE_SUB_CONFIGS},
@ -413,6 +416,10 @@ void options_parse(int argc, char *argv[])
option.alert = alert_option_parse(optarg); option.alert = alert_option_parse(optarg);
break; break;
case OPT_MUTE:
option.mute = true;
break;
case 'v': case 'v':
printf("tio v%s\n", VERSION); printf("tio v%s\n", VERSION);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);