mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-03 15:29:29 +00:00
json: Set json format at the end of parsing globals
If we set and unset json format duging the time we are parsing globals we may end up with inconsistent outputs on errors. For exmaple: $ swupd diagnose -d -1 --json-output will have a different output then: $ swupd diagnose --json-output -d -1 Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
+3
-1
@@ -62,6 +62,7 @@ static int log_level = LOG_INFO;
|
||||
static bool quiet = false;
|
||||
static bool debug = false;
|
||||
static bool verbose = false;
|
||||
static bool json_format = false;
|
||||
|
||||
static void set_json_format(bool on)
|
||||
{
|
||||
@@ -595,7 +596,7 @@ static bool global_parse_opt(int opt, char *optarg)
|
||||
}
|
||||
return true;
|
||||
case 'j':
|
||||
set_json_format(optarg_to_bool(optarg));
|
||||
json_format = optarg_to_bool(optarg);
|
||||
return true;
|
||||
case FLAG_NO_PROGRESS:
|
||||
progress_set_enabled(!optarg_to_bool(optarg));
|
||||
@@ -767,6 +768,7 @@ int global_parse_options(int argc, char **argv, const struct global_options *opt
|
||||
log_level = LOG_INFO_VERBOSE;
|
||||
}
|
||||
log_set_level(log_level);
|
||||
set_json_format(json_format);
|
||||
|
||||
if (!config_found) {
|
||||
debug("No configuration file was found\n");
|
||||
|
||||
@@ -153,6 +153,7 @@ static void start_step()
|
||||
} else {
|
||||
progress_function(current_step_title, current_step, total_steps,
|
||||
0);
|
||||
last_percentage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user