cli: add explicit option for pretty printing command result data
No-op for now, but allows making output more machine readable Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
d07c48fa09
commit
1735da8e4c
1 changed files with 21 additions and 18 deletions
|
@ -11,8 +11,26 @@ let history = [];
|
||||||
let history_edit;
|
let history_edit;
|
||||||
let history_idx = -1;
|
let history_idx = -1;
|
||||||
let cur_line;
|
let cur_line;
|
||||||
let interactive;
|
let interactive, script_mode, raw_mode;
|
||||||
let script_mode;
|
|
||||||
|
while (length(ARGV) > 0) {
|
||||||
|
let cmd = ARGV[0];
|
||||||
|
if (substr(cmd, 0, 1) != "-")
|
||||||
|
break;
|
||||||
|
|
||||||
|
shift(ARGV);
|
||||||
|
switch (cmd) {
|
||||||
|
case '-i':
|
||||||
|
interactive = true;
|
||||||
|
break;
|
||||||
|
case '-s':
|
||||||
|
script_mode = true;
|
||||||
|
break;
|
||||||
|
case '-R':
|
||||||
|
raw_mode = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let el;
|
let el;
|
||||||
let model = datamodel.new({
|
let model = datamodel.new({
|
||||||
|
@ -23,6 +41,7 @@ let model = datamodel.new({
|
||||||
warn(msg + "\n");
|
warn(msg + "\n");
|
||||||
el.refresh_prompt();
|
el.refresh_prompt();
|
||||||
},
|
},
|
||||||
|
opt_pretty_print: !raw_mode
|
||||||
});
|
});
|
||||||
let uloop = model.uloop;
|
let uloop = model.uloop;
|
||||||
model.add_modules();
|
model.add_modules();
|
||||||
|
@ -676,22 +695,6 @@ el = uline.new({
|
||||||
key_input_list: [ "?", "\t", "\x03", "\x12" ]
|
key_input_list: [ "?", "\t", "\x03", "\x12" ]
|
||||||
});
|
});
|
||||||
|
|
||||||
while (length(ARGV) > 0) {
|
|
||||||
let cmd = ARGV[0];
|
|
||||||
if (substr(cmd, 0, 1) != "-")
|
|
||||||
break;
|
|
||||||
|
|
||||||
shift(ARGV);
|
|
||||||
switch (cmd) {
|
|
||||||
case '-i':
|
|
||||||
interactive = true;
|
|
||||||
break;
|
|
||||||
case '-s':
|
|
||||||
script_mode = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SCRIPT_NAME != "cli") {
|
if (SCRIPT_NAME != "cli") {
|
||||||
let cur_ctx = ctx.select([ basename(SCRIPT_NAME) ]);
|
let cur_ctx = ctx.select([ basename(SCRIPT_NAME) ]);
|
||||||
if (cur_ctx && cur_ctx != ctx && !cur_ctx.errors) {
|
if (cur_ctx && cur_ctx != ctx && !cur_ctx.errors) {
|
||||||
|
|
Loading…
Reference in a new issue