At Wed, 13 Nov 2013 21:17:03 +0800, Liu Yuan wrote: > > On Wed, Nov 13, 2013 at 09:59:41PM +0900, Hitoshi Mitake wrote: > > Current dog command dies when user invokes "dog node log level set" without > > any > > arguments because of its subcommand design. This patch removes this > > limitation. > > > > Signed-off-by: Hitoshi Mitake <[email protected]> > > --- > > > > v3: declare the depth as a static variable > > > > v2: define do_generic_subcommand() as a macro for a common case (depth == 0) > > > > dog/common.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/dog/common.c b/dog/common.c > > index 4480b99..8c9b326 100644 > > --- a/dog/common.c > > +++ b/dog/common.c > > @@ -227,7 +227,9 @@ int send_light_req(const struct node_id *nid, struct > > sd_req *hdr) > > int do_generic_subcommand(struct subcommand *sub, int argc, char **argv) > > { > > int i, ret; > > + static int depth = -1; > > > > + depth++; > > for (i = 0; sub[i].name; i++) { > > if (!strcmp(sub[i].name, argv[optind])) { > > unsigned long flags = sub[i].flags; > > @@ -240,7 +242,7 @@ int do_generic_subcommand(struct subcommand *sub, int > > argc, char **argv) > > } > > } > > > > - if (flags & CMD_NEED_ARG && argc < 5) > > + if (flags & CMD_NEED_ARG && argc < 5 + depth) > > subcommand_usage(argv[1], argv[2], EXIT_USAGE); > > optind++; > > ret = sub[i].fn(argc, argv); > > @@ -250,6 +252,7 @@ int do_generic_subcommand(struct subcommand *sub, int > > argc, char **argv) > > } > > } > > > > + depth--; > > subcommand_usage(argv[1], argv[2], EXIT_FAILURE); > > return EXIT_FAILURE; > > } > > Applied thanks. I think subcommand_usage need fixes too.
Yes, I'll fix the broken usage printing later. Thanks, Hitoshi -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
