static int noOpcodes = 0;
static int (*beforeProc) (struct cmd_syndesc * ts, void *beforeRock) = NULL;
static int (*afterProc) (struct cmd_syndesc * ts, void *afterRock) = NULL;
+static int enablePositional = 1;
static void *beforeRock, *afterRock;
static char initcmd_opcode[] = "initcmd"; /*Name of initcmd opcode */
return 0; /* all done */
}
+void
+cmd_DisablePositionalCommands(void)
+{
+ enablePositional = 0;
+}
+
int
cmd_IsAdministratorCommand(struct cmd_syndesc *as)
{
* out of positional mode, and from that point on, expect a switch
* before any particular token. */
- positional = 1; /* Are we still in the positional region of the cmd line? */
+ positional = enablePositional; /* Accepting positional cmds ? */
i = noOpcodes ? 1 : 2;
SetupExpandsFlag(ts);
for (; i < argc; i++) {
extern int cmd_ParseLine(char *aline, char **argv, afs_int32 * an,
afs_int32 amaxn);
extern int cmd_IsAdministratorCommand(struct cmd_syndesc *as);
+extern void cmd_DisablePositionalCommands(void);
extern void PrintSyntax(struct cmd_syndesc *as);
extern void PrintFlagHelp(struct cmd_syndesc *as);
int code;
int tc;
- plan(25);
+ plan(27);
initialize_CMD_error_table();
is_int(CMD_NOTLIST, code, "too many parameters fails as expected");
cmd_FreeArgv(tv);
-
-
-
/* Positional parameters */
code = cmd_ParseLine("foo bar -flag", tv, &tc, 100);
is_int(0, code, "cmd_ParseLine succeeds");
is_int(CMD_UNKNOWNSWITCH, code, "ambiguous abbreviations correctly fail");
cmd_FreeArgv(tv);
+ /* Disable positional commands */
+ cmd_DisablePositionalCommands();
+ code = cmd_ParseLine("foo bar -flag", tv, &tc, 100);
+ is_int(0, code, "cmd_ParseLine succeeds");
+ code = cmd_Dispatch(tc, tv);
+ is_int(3359746, code, "positional parameters can be disabled");
+ cmd_FreeArgv(tv);
+
return 0;
}
+