mirror of
https://github.com/troglobit/finit.git
synced 2026-10-24 11:54:36 +00:00
New cmdline options to control debug and progress/status
Modeled after systemd.show_status, currently without the 'auto' setting. - finit.debug[=bool] - finit.show_status[=bool] - finit.status_style[=old,classic,new,modern] Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
35e4e0d073
commit
70ca64a392
5 files changed
+74
-19
No files matched your search
+45
-3
@@ -75,11 +75,53 @@ static void hide_args(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
int get_bool(char *ptr, int default_value)
|
||||
{
|
||||
if (string_compare(ptr, "true") || string_compare(ptr, "on") || string_compare(ptr, "1"))
|
||||
return 1;
|
||||
if (string_compare(ptr, "false") || string_compare(ptr, "off") || string_compare(ptr, "0"))
|
||||
return 0;
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* finit.debug = [on,off]
|
||||
* finit.show_status = [on,off]
|
||||
*/
|
||||
static void parse_finit_opts(char *opt)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
ptr = strchr(opt, '=');
|
||||
if (ptr)
|
||||
*ptr++ = 0;
|
||||
|
||||
if (string_compare(opt, "debug")) {
|
||||
debug = get_bool(ptr, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string_compare(opt, "status_style")) {
|
||||
if (string_compare(ptr, "old") || string_compare(ptr, "classic"))
|
||||
show_progress(PROGRESS_CLASSIC);
|
||||
else
|
||||
show_progress(PROGRESS_MODERN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string_compare(opt, "show_status")) {
|
||||
show_progress(get_bool(ptr, 1) ? PROGRESS_DEFAULT : PROGRESS_SILENT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_arg(char *arg)
|
||||
{
|
||||
/* Catches finit_debug, --debug, and debug */
|
||||
if (strstr(arg, "debug"))
|
||||
debug = 1;
|
||||
if (!strncmp(arg, "finit.", 6)) {
|
||||
parse_finit_opts(&arg[6]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string_compare(arg, "rescue") || string_compare(arg, "recover"))
|
||||
rescue = 1;
|
||||
|
||||
Reference in new issue
Block a user