aboutsummaryrefslogtreecommitdiff
path: root/jim-subcmd.h
diff options
context:
space:
mode:
Diffstat (limited to 'jim-subcmd.h')
-rw-r--r--jim-subcmd.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/jim-subcmd.h b/jim-subcmd.h
index ab30f37..2d05821 100644
--- a/jim-subcmd.h
+++ b/jim-subcmd.h
@@ -31,6 +31,11 @@ typedef struct {
unsigned short flags; /* JIM_MODFLAG_... plus custom flags */
} jim_subcmd_type;
+/* This makes it easy to define a jim_subcmd_type array with function=NULL
+ * see jim-namespace.c for an example
+ */
+#define JIM_DEF_SUBCMD(name, args, minargs, maxargs) { name, args, NULL, minargs, maxargs }
+
/**
* Looks up the appropriate subcommand in the given command table and return
* the command function which implements the subcommand.
@@ -70,6 +75,13 @@ 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);
+/**
+ * Sets an error result indicating the usage of the subcmd 'ct'.
+ * Typically this will be called with the result of Jim_ParseSubCmd() after
+ * additional checks if the args are wrong.
+ */
+void Jim_SubCmdArgError(Jim_Interp *interp, const jim_subcmd_type *ct, Jim_Obj *subcmd);
+
#ifdef __cplusplus
}
#endif