aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoff Gustafson <geoff@linux.intel.com>2017-05-15 12:11:36 -0700
committerJimmy Huang <jimmy.huang@linux.intel.com>2017-05-15 12:11:36 -0700
commit8a5bafc5a2fc732c0b41ddf25ea9c4664d138612 (patch)
treeb44da1d25929a8f0c799685dc25bcf58c2e546df
parent15742e9c6a495489888f96b6612df63bddd87a6c (diff)
[ashell] Simplify help command list for IDE (#1156)
Also, fix description of ls, reorder command list for clarity, improve help formatting. Signed-off-by: Geoff Gustafson <geoff@linux.intel.com>
-rw-r--r--src/ashell/shell-state.c71
-rw-r--r--src/ashell/shell-state.h1
2 files changed, 46 insertions, 26 deletions
diff --git a/src/ashell/shell-state.c b/src/ashell/shell-state.c
index 127301c..de6b957 100644
--- a/src/ashell/shell-state.c
+++ b/src/ashell/shell-state.c
@@ -23,6 +23,10 @@
#include "ihex-handler.h"
#include "jerry-code.h"
+#ifndef CONFIG_USB_CDC_ACM
+#define CONFIG_IDE
+#endif
+
#ifdef CONFIG_REBOOT
//TODO Waiting for patch https://gerrit.zephyrproject.org/r/#/c/3161/
#ifdef CONFIG_BOARD_ARDUINO_101
@@ -600,33 +604,43 @@ int32_t ashell_set_bootcfg(char *buf)
return RET_OK;
}
-#define ASHELL_COMMAND(name,syntax,cmd) {name, syntax, cmd}
+#ifdef CONFIG_IDE
+// skip listing this command in the IDE by setting description string empty
+#define IDE_SKIP(str) ""
+#else
+#define IDE_SKIP(str) str
+#endif
static const struct ashell_cmd commands[] =
{
- ASHELL_COMMAND("help", "This help", ashell_help),
- ASHELL_COMMAND("eval", "Evaluate JavaScript in real time" ,ashell_js_immediate_mode),
- ASHELL_COMMAND("clear", "Clear the terminal screen" ,ashell_clear),
- ASHELL_COMMAND("load", "[FILE] Saves the input text into a file" ,ashell_read_data),
- ASHELL_COMMAND("run", "[FILE] Runs the JavaScript program in the file" ,ashell_run_javascript),
- ASHELL_COMMAND("parse", "[FILE] Check if the JS syntax is correct" ,ashell_parse_javascript),
- ASHELL_COMMAND("stop", "Stops current JavaScript execution" ,ashell_stop_javascript),
- ASHELL_COMMAND("boot", "[FILE] Set the file that should run at boot" ,ashell_set_bootcfg),
-
- ASHELL_COMMAND("ls", "[FILE] List directory contents or file stat" ,ashell_list_dir),
- ASHELL_COMMAND("cat", "[FILE] Print the file contents of a file" ,ashell_print_file),
- ASHELL_COMMAND("du", "[FILE] Estimate file space usage" ,ashell_disk_usage),
- ASHELL_COMMAND("rm", "[FILE] Remove file or directory" ,ashell_remove_file),
- ASHELL_COMMAND("mv", "[SOURCE] [DEST] Move a file to destination" ,ashell_rename),
-
-// ASHELL_COMMAND("rmdir", "[TODO]" ,ashell_remove_dir),
-// ASHELL_COMMAND("mkdir", "[TODO]" ,ashell_make_dir),
- ASHELL_COMMAND("error", "Prints an error using JerryScript" ,ashell_error),
- ASHELL_COMMAND("echo", "[on/off] Sets console echo mode on/off" ,ashell_set_echo_mode),
-
- ASHELL_COMMAND("set", "Sets the input mode for 'load' accept data\r\n\ttransfer raw\r\n\ttransfer ihex\t",ashell_set_state),
- ASHELL_COMMAND("get", "Get states on the shell" ,ashell_get_state),
- ASHELL_COMMAND("reboot","Reboots the device" ,ashell_reboot)
+ // CMD ARGS DESCRIPTION IMPL
+ {"help", "", "This help", ashell_help},
+ {"eval", "", "Evaluate JavaScript in real time",
+ ashell_js_immediate_mode},
+ {"load", "FILE", IDE_SKIP("Saves the input text into a file"),
+ ashell_read_data},
+ {"run", "FILE", "Runs the JavaScript program in the file",
+ ashell_run_javascript},
+ {"parse", "FILE", IDE_SKIP("Check if the JS syntax is correct"),
+ ashell_parse_javascript},
+ {"stop", "", "Stops current JavaScript execution",
+ ashell_stop_javascript},
+ {"ls", "", "List all files", ashell_list_dir},
+ {"cat", "FILE", "Print the file contents of a file", ashell_print_file},
+ {"du", "FILE", IDE_SKIP("Estimate file space usage"),
+ ashell_disk_usage},
+ {"rm", "FILE", "Remove file or directory", ashell_remove_file},
+ {"mv", "F1 F2", "Move file F1 to destination F2", ashell_rename},
+ {"clear", "", "Clear the terminal screen", ashell_clear},
+ {"boot", "FILE", "Set the file that should run at boot",
+ ashell_set_bootcfg},
+ {"reboot", "", "Reboots the device", ashell_reboot},
+
+ // undocumented commands used by IDE
+ {"error", "", "", ashell_error},
+ {"echo", "on/off", "", ashell_set_echo_mode},
+ {"set", "", "", ashell_set_state},
+ {"get", "", "", ashell_get_state},
};
#define ASHELL_COMMANDS_COUNT (sizeof(commands)/sizeof(*commands))
@@ -636,8 +650,13 @@ int32_t ashell_help(char *buf)
comms_print("'A Shell' bash\r\n\r\n");
comms_print("Commands list:\r\n");
for (uint32_t t = 0; t < ASHELL_COMMANDS_COUNT; t++) {
- comms_print(commands[t].cmd_name);
- comms_write_buf("\t", 1);
+ // skip commands with empty description
+ if (!commands[t].syntax[0]) {
+ continue;
+ }
+ char buf[40];
+ snprintf(buf, 40, " %s\t%s\t", commands[t].cmd_name, commands[t].args);
+ comms_print(buf);
comms_print(commands[t].syntax);
comms_write_buf("\r\n", 2);
}
diff --git a/src/ashell/shell-state.h b/src/ashell/shell-state.h
index 3a16389..26d3fc2 100644
--- a/src/ashell/shell-state.h
+++ b/src/ashell/shell-state.h
@@ -35,6 +35,7 @@ typedef int32_t(*ashell_cmd)(char *buf);
struct ashell_cmd
{
const char *cmd_name;
+ const char *args;
const char *syntax;
ashell_cmd cb;
};