src/ao_cmd: Shave off bytes from doc strings
authorAnthony Towns <aj@erisian.com.au>
Sun, 27 Feb 2011 01:11:12 +0000 (11:11 +1000)
committerKeith Packard <keithp@keithp.com>
Mon, 7 Mar 2011 08:01:46 +0000 (00:01 -0800)
Switch to using { func, "X args\0Desc" } to specify command, saving
a char field by looking at help[0] instead, and reduce help length by
doing alignment with printf instead of hardcoded spaces.

15 files changed:
src/ao.h
src/ao_adc.c
src/ao_cmd.c
src/ao_config.c
src/ao_dbg.c
src/ao_flight_test.c
src/ao_gps_skytraq.c
src/ao_host.h
src/ao_ignite.c
src/ao_log.c
src/ao_monitor.c
src/ao_packet_master.c
src/ao_radio.c
src/ao_serial.c
src/ao_storage.c

index c2d7d22bfdbc22cd0be50d4ed16f543c16a3e15b..791064e8d25c7b6c3e5e52c2e3d0c7beaf56cdb4 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -380,7 +380,6 @@ uint8_t
 ao_match_word(__code char *word);
 
 struct ao_cmds {
-       char            cmd;
        void            (*func)(void);
        const char      *help;
 };
index 3adf9b2e70277526e252770c7071dec7a400d0b1..9990a1fdaeecf75df906339d56a0b56bcebc0685 100644 (file)
@@ -90,8 +90,8 @@ ao_adc_dump(void) __reentrant
 }
 
 __code struct ao_cmds ao_adc_cmds[] = {
-       { 'a',  ao_adc_dump,    "a                                  Display current ADC values" },
-       { 0,    ao_adc_dump, NULL },
+       { ao_adc_dump,  "a\0Display current ADC values" },
+       { 0, NULL },
 };
 
 void
index a54a2316f006fb4a20909d430389413ac66922c1..6007773c96cdaba0a8eb6ca63ea4c83580bc7b9f 100644 (file)
@@ -237,8 +237,10 @@ help(void)
        puts(help_txt);
        for (cmds = 0; cmds < ao_ncmds; cmds++) {
                cs = ao_cmds[cmds];
-               for (cmd = 0; cs[cmd].cmd != '\0'; cmd++)
-                       puts(cs[cmd].help);
+               for (cmd = 0; cs[cmd].func; cmd++)
+                       printf("%-45s %s\n",
+                               cs[cmd].help,
+                               cs[cmd].help+1+strlen(cs[cmd].help));
        }
 }
 
@@ -282,8 +284,8 @@ ao_cmd(void)
                func = (void (*)(void)) NULL;
                for (cmds = 0; cmds < ao_ncmds; cmds++) {
                        cs = ao_cmds[cmds];
-                       for (cmd = 0; cs[cmd].cmd != '\0'; cmd++)
-                               if (cs[cmd].cmd == c) {
+                       for (cmd = 0; cs[cmd].func; cmd++)
+                               if (cs[cmd].help[0] == c) {
                                        func = cs[cmd].func;
                                        break;
                                }
@@ -301,12 +303,12 @@ ao_cmd(void)
 __xdata struct ao_task ao_cmd_task;
 
 __code struct ao_cmds  ao_base_cmds[] = {
-       { '?', help,            "?                                  Print this message" },
-       { 'T', ao_task_info,    "T                                  Show task states" },
-       { 'E', echo,            "E <0 off, 1 on>                    Set command echo mode" },
-       { 'r', ao_reboot,       "r eboot                            Reboot" },
-       { 'v', version,         "v                                  Show version" },
-       { 0,    help,   NULL },
+       { help,         "?\0Print this message" },
+       { ao_task_info, "T\0Show task states" },
+       { echo,         "E <0 off, 1 on>\0Set command echo mode" },
+       { ao_reboot,    "r eboot\0Reboot" },
+       { version,      "v\0Show version" },
+       { 0,    NULL },
 };
 
 void
index cd56b47314a62d091bc7e311411a8e3ac11c5848..c6d36247f1b5504f6e034cd879bdbe2df23834ab 100644 (file)
@@ -439,8 +439,8 @@ ao_config_write(void) __reentrant
 #endif
 
 __code struct ao_cmds ao_config_cmds[] = {
-       { 'c',  ao_config_set,  "c <var> <value>                    Set config variable (? for help, s to show)" },
-       { '\0', ao_config_set, NULL },
+       { ao_config_set,        "c <var> <value>\0Set config variable (? for help, s to show)" },
+       { 0, NULL },
 };
 
 void
index 0d9ec8c0db958a306b9b3b5bc95f1bdf0e14ac3e..493715600b169e2fcbbeab74d5f5fecaac6f64b6 100644 (file)
@@ -348,13 +348,13 @@ debug_output(void)
 }
 
 __code struct ao_cmds ao_dbg_cmds[7] = {
-       { 'D',  debug_enable,   "D                                  Enable debug mode" },
-       { 'G',  debug_get,      "G <count>                          Get data from debug port" },
-       { 'I',  debug_input,    "I <count> <addr>                   Input <count> bytes to target at <addr>" },
-       { 'O',  debug_output,   "O <count> <addr>                   Output <count> bytes to target at <addr>" },
-       { 'P',  debug_put,      "P <byte> ...                       Put data to debug port" },
-       { 'R',  debug_reset,    "R                                  Reset target" },
-       { 0, debug_reset,       0 },
+       { debug_enable, "D\0Enable debug mode" },
+       { debug_get,    "G <count>\0Get data from debug port" },
+       { debug_input,  "I <count> <addr>\0Input <count> bytes to target at <addr>" },
+       { debug_output, "O <count> <addr>\0Output <count> bytes to target at <addr>" },
+       { debug_put,    "P <byte> ...\0Put data to debug port" },
+       { debug_reset,  "R\0Reset target" },
+       { 0, NULL },
 };
 
 void
index 8ce94895026213b2954124d7f548d733030fb6d7..0c2006d54907c6ac90f8c997a194ea4c1759cff4 100644 (file)
@@ -114,7 +114,6 @@ const char const * const ao_state_names[] = {
 };
 
 struct ao_cmds {
-       char            cmd;
        void            (*func)(void);
        const char      *help;
 };
index 4d4ca59215bf4512408be7968e82a08f12c8cee4..d286a30a8bea934aca27eb3b76811f8b499c8596 100644 (file)
@@ -471,8 +471,8 @@ gps_dump(void) __reentrant
 }
 
 __code struct ao_cmds ao_gps_cmds[] = {
-       { 'g', gps_dump,        "g                                  Display current GPS values" },
-       { 0,   gps_dump, NULL },
+       { gps_dump,     "g\0Display current GPS values" },
+       { 0, NULL },
 };
 
 void
index a96b76291d83eaf4643a6dfe8dfd417b25d5945a..65c25fe53d619c89492c10abddf4658b9d276487 100644 (file)
@@ -112,7 +112,6 @@ const char const * const ao_state_names[] = {
 };
 
 struct ao_cmds {
-       char            cmd;
        void            (*func)(void);
        const char      *help;
 };
index 603fcd25f3e37105487ad1005894cfdbabcc9815..798ba9b45ae4fc774e1e793b2e03b304a6068cad 100644 (file)
@@ -154,9 +154,9 @@ ao_ignite_test(void)
 }
 
 __code struct ao_cmds ao_ignite_cmds[] = {
-       { 'i',  ao_ignite_manual,       "i <key> {main|drogue}              Fire igniter. <key> is doit with D&I" },
-       { 't',  ao_ignite_test,         "t                                  Test igniter continuity" },
-       { 0,    ao_ignite_manual,       NULL },
+       { ao_ignite_manual,     "i <key> {main|drogue}\0Fire igniter. <key> is doit with D&I" },
+       { ao_ignite_test,       "t\0Test igniter continuity" },
+       { 0,    NULL },
 };
 
 __xdata struct ao_task ao_igniter_task;
index 099c5f6ff9683aebf4a7048f2ed212e71578f60e..1b10961d1d45a151657d29d317b142fc19880f47 100644 (file)
@@ -390,9 +390,9 @@ ao_log_delete(void) __reentrant
 
 
 __code struct ao_cmds ao_log_cmds[] = {
-       { 'l',  ao_log_list,    "l                                  List stored flight logs" },
-       { 'd',  ao_log_delete,  "d <flight-number>                  Delete stored flight" },
-       { 0,    ao_log_delete,  NULL },
+       { ao_log_list,  "l\0List stored flight logs" },
+       { ao_log_delete,        "d <flight-number>\0Delete stored flight" },
+       { 0,    NULL },
 };
 
 void
index 4ba3da6d848949b27e31495bbde9af68fb56c9eb..9c4be6fbd2be6a8cdde664d8f39d00adcc2a1b4c 100644 (file)
@@ -96,8 +96,8 @@ set_monitor(void)
 }
 
 __code struct ao_cmds ao_monitor_cmds[] = {
-       { 'm',  set_monitor,    "m <0 off, 1 on>                    Enable/disable radio monitoring" },
-       { 0,    set_monitor,    NULL },
+       { set_monitor,  "m <0 off, 1 on>\0Enable/disable radio monitoring" },
+       { 0,    NULL },
 };
 
 void
index 5f79885c3a4fad5085a7318703245a72520eef30..5c4ab0ddd3f8b9914e47df9257a978d7bd8091f0 100644 (file)
@@ -133,8 +133,8 @@ ao_packet_forward(void) __reentrant
 
 
 __code struct ao_cmds ao_packet_master_cmds[] = {
-       { 'p',  ao_packet_forward,      "p                                  Remote packet link." },
-       { 0,    ao_packet_forward,      NULL },
+       { ao_packet_forward,    "p\0Remote packet link." },
+       { 0,    NULL },
 };
 
 void
index d156f54349caefffa33bc24bc638b560e2d3982e..d7c00213dfac795e312d29004df08b9278d9a8ad 100644 (file)
@@ -455,8 +455,8 @@ ao_radio_test(void)
 }
 
 __code struct ao_cmds ao_radio_cmds[] = {
-       { 'C',  ao_radio_test,  "C <1 start, 0 stop, none both>     Radio carrier test" },
-       { 0,    ao_radio_test,  NULL },
+       { ao_radio_test,        "C <1 start, 0 stop, none both>\0Radio carrier test" },
+       { 0,    NULL },
 };
 
 void
index a48734c2f22793a957fb9575f6f5d0d2e0d21c26..dd383fca18ff141a5ffd7c0af0f923f746437eca 100644 (file)
@@ -93,8 +93,8 @@ monitor_serial(void)
 }
 
 __code struct ao_cmds ao_serial_cmds[] = {
-       { 'M', monitor_serial,          "M <enable>                         Monitor serial data" },
-       { 0, monitor_serial, NULL },
+       { monitor_serial,               "M <enable>\0Monitor serial data" },
+       { 0, NULL },
 };
 
 static const struct {
index 709259ee977cee2305fcabc04c18efddc1c3a56d..9f0f75fb26719429ed4d9d68c35e087fa65bffa8 100644 (file)
@@ -166,14 +166,12 @@ ao_storage_info(void) __reentrant
 }
 
 __code struct ao_cmds ao_storage_cmds[] = {
-       { 'f', ao_storage_info, "f                                  Show storage info" },
-       { 'e', ao_storage_dump, "e <block>                          Dump a block of flash data" },
-#if 0
-       { 'w', ao_storage_store, "w <block> <start> <len> <data> ... Write data to flash" },
+#ifdef HAS_STORAGE_DBG
+       { ao_storage_store, "w <block> <start> <len> <data> ...\0Write data to flash" },
 #endif
-       { 'z', ao_storage_zap,   "z <block>                          Erase flash containing <block>" },
-       { 'Z', ao_storage_zapall,"Z <key>                            Erase all logs. <key> is doit with D&I" },
-       { 0,   ao_storage_zap, NULL },
+       { ao_storage_zap, "z <block>\0Erase flash containing <block>" },
+       { ao_storage_zapall,"Z <key>\0Erase all logs. <key> is doit with D&I" },
+       { 0, NULL },
 };
 
 void