[ovs-dev] [PATCH] command-line: Add function to print all options.
Ben Pfaff
blp at nicira.com
Thu Oct 16 22:20:01 UTC 2014
I understand now.
I agree that it makes sense to have a way to print the usage in an
easily parsed way. But I don't think that making --help and "help" do
different things is a good distinction, because both forms are common
ways to get a program to give human-readable help. How about using a
different word that is not in as common use, such as a "usage"
command?
I think this is OK, then.
It might be possible to have the command-line code parse "usage" so
that min_args and max_args do not have to be specified. That is not
necessary as part of a first patch, but it might be a nice refinement
later.
On Thu, Oct 16, 2014 at 02:50:40PM -0700, Alex Wang wrote:
> Sorry for the confusion, I mean:
>
> `command --help (or -h)` still prints out the usage page,
>
> `command help` prints the function format (usage).
>
> What do you think?
>
> Thanks,
> Alex Wang,
>
>
> On Thu, Oct 16, 2014 at 2:41 PM, Ben Pfaff <blp at nicira.com> wrote:
>
> > On Wed, Oct 15, 2014 at 09:51:54AM -0700, Alex Wang wrote:
> > > I'm changing the 'struct command' like this:
> > >
> > > diff --git a/lib/command-line.h b/lib/command-line.h
> > > index 157cb58..57fdff5 100644
> > > --- a/lib/command-line.h
> > > +++ b/lib/command-line.h
> > > @@ -27,7 +27,7 @@ struct command {
> > > const char *name;
> > > + const char *usage;
> > > int min_args;
> > > int max_args;
> > > - void (*handler)(int argc, char *argv[]);
> > > + void (*handler)(int argc, char *argv[], void *aux);
> > > };
> > >
> > > The 'usage' will record the format of cmds. (e.g. the 'usage' in 'struct
> > > unixctl_command'). The 'help' subcommand will print the command with
> > > usage and bash completion script will parse it.
> > >
> > > The 'handler()' change is for eliminating the 'struct dpctl_command'.
> > >
> > > I saw this will affect a ton of cmd source files e.g. ovsdb-tool,
> > > ovs-benchmark
> > > which uses 'struct command'.
> > >
> > > So, want to know what you think about doing this.
> >
> > I think it could be a nice step forward but I worry that it will make
> > the --help output harder to read.
> >
More information about the dev
mailing list