mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-25 10:04:14 +03:00
ostadmin: fix command line handling in the builtins
Common code was duplicating the command name and not shifting arguments properly, which thus required the builtins to be aware of it, instead of being treated like subcommands.
This commit is contained in:
parent
22aa38a7da
commit
edf69d6283
@ -368,15 +368,15 @@ ot_admin_builtin_deploy (int argc, char **argv, GError **error)
|
||||
if (!g_option_context_parse (context, &argc, &argv, error))
|
||||
goto out;
|
||||
|
||||
if (argc < 3)
|
||||
if (argc < 2)
|
||||
{
|
||||
ot_util_usage_error (context, "NAME must be specified", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
deploy_target = argv[2];
|
||||
if (argc > 3)
|
||||
revision = argv[3];
|
||||
deploy_target = argv[1];
|
||||
if (argc > 2)
|
||||
revision = argv[2];
|
||||
|
||||
if (!do_checkout (self, deploy_target, revision, cancellable, error))
|
||||
goto out;
|
||||
|
@ -61,14 +61,15 @@ prep_builtin_argv (const char *builtin,
|
||||
{
|
||||
int i;
|
||||
char **cmd_argv;
|
||||
|
||||
cmd_argv = g_new0 (char *, argc + 2);
|
||||
|
||||
cmd_argv[0] = (char*)builtin;
|
||||
for (i = 0; i < argc; i++)
|
||||
cmd_argv[i+1] = argv[i];
|
||||
cmd_argv[i+1] = NULL;
|
||||
*out_argc = argc+1;
|
||||
|
||||
/* Should be argc - 1 + 1, to account for
|
||||
the first argument (removed) and for NULL pointer */
|
||||
cmd_argv = g_new0 (char *, argc);
|
||||
|
||||
for (i = 0; i < argc-1; i++)
|
||||
cmd_argv[i] = argv[i+1];
|
||||
cmd_argv[i] = NULL;
|
||||
*out_argc = argc-1;
|
||||
*out_argv = cmd_argv;
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ ot_admin_main (int argc,
|
||||
goto out;
|
||||
}
|
||||
|
||||
prep_builtin_argv (cmd, argc-1, argv+1, &cmd_argc, &cmd_argv);
|
||||
prep_builtin_argv (cmd, argc, argv, &cmd_argc, &cmd_argv);
|
||||
|
||||
if (!builtin->fn (cmd_argc, cmd_argv, &error))
|
||||
goto out;
|
||||
|
Loading…
x
Reference in New Issue
Block a user