summaryrefslogtreecommitdiff
path: root/jim-subcmd.h
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-01-24 10:38:39 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:39 +1000
commitb6cb7fb49a02a24d4c9435d3c010bb1606c3d6fe (patch)
treecb4acbb3cd014621aac0431a08c8c78e70dce9c3 /jim-subcmd.h
parentea9e4bbb490eb2be047f46c83ff32f3d5243cd71 (diff)
Rework/improve jim subcmd handling
*: -usage and -help do not generate an error *: -help <cmd> where the cmd is invalid now generates a correct response *: Add Jim_CheckCmdUsage() so top level commands can also be checked and print usage *: Fix the FULLARGV flag which was accidently set to the same value as the HIDDEN flag *: If -help is specified for an invalid or amibiguous subcmd, show all commands ------------------------------------------------------------------------
Diffstat (limited to 'jim-subcmd.h')
-rw-r--r--jim-subcmd.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/jim-subcmd.h b/jim-subcmd.h
index 4525837..b06a670 100644
--- a/jim-subcmd.h
+++ b/jim-subcmd.h
@@ -7,7 +7,7 @@
#include <jim.h>
#define JIM_MODFLAG_HIDDEN 0x0001 /* Don't show the subcommand in usage or commands */
-#define JIM_MODFLAG_FULLARGV 0x0001 /* Subcmd proc gets called with full argv */
+#define JIM_MODFLAG_FULLARGV 0x0002 /* Subcmd proc gets called with full argv */
/* Custom flags start at 0x0100 */
@@ -66,4 +66,18 @@ int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
*/
int Jim_CallSubCmd(Jim_Interp *interp, const jim_subcmd_type *ct, int argc, Jim_Obj *const *argv);
+/**
+ * Standard processing for a command.
+ *
+ * This does the '-help' and '-usage' check and the number of args checks.
+ * for a top level command against a single 'jim_subcmd_type' structure.
+ *
+ * Additionally, if command_table->function is set, it should point to a sub command table
+ * and '-subhelp ?subcmd?', '-subusage' and '-subcommands' are then also recognised.
+ *
+ * Returns 0 if user requested usage, -1 on arg error, 1 if OK to process.
+ */
+int
+Jim_CheckCmdUsage(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
+
#endif