For example, current output is:
# dladm show-link -j
dladm: unrecognized option '-j'
New output will be:
# dladm show-link -j
dladm: unrecognized option '-j'
usage: show-link [-p] [-s [-i <interval>]] [<name>]
Shows link configuration information (the default) or statistics,
either for all data-link or for the specified link name. By
default, the system in configured with one data-link for each
known network device.
The text will be the same as from the man pages of dladm(1m).
If the subcommand is misstyped or missing, the current usage message
will still be displayed. This message consists of all the commands and
options.
# dladm sho-link
dladm: unknown subcommand 'sho-link'
usage: dladm <subcommand> <args> ...
show-link [-p] [-s [-i <interval>]] [<name>]
show-dev [-p] [-s [-i <interval>]] [<dev>]
...
In terms of changes to the code (usr/src/cmd/dladm/dladm.c), here are
some snippets:
#define CMD_SHOW_LINK 1
#define CMD_RENAME_LINK 2
...
/* current usage() prints all the subcommands */
static void
usage(void)
{
int i;
(void) fprintf(stderr, gettext("usage: dladm <subcommand>
<args> ...\n"));
for (i = CMD_MIN; i <= CMD_MAX; i++) {
(void) fprintf(stderr, "%s\n", command_usage(i));
}
}
/* returns the usage for the given subcommand */
static char*
command_usage(int cmd_num)
{
switch (cmd_num) {
case CMD_SHOW_LINK:
return (gettext("\tshow-link\t[-p] [-s [-i <interval>]]
[<name>]"));
...
default:
return ("");
}
/* NOTREACHED */
return (NULL);
}
/* returns the short summary of the given subcommand */
static char*
command_help_text(int cmd_num)
{
switch (cmd_num) {
case CMD_SHOW_LINK:
return (gettext("\tShows link configuration information
(the default) ..."));
...
default:
return ("");
}
/* NOTREACHED */
return (NULL);
}
/* new argument: cmd_num */
/* all die_opterr() call will be supplemented with the subcommand */
/* prints usage and summary for given subcommand */
static void
die_opterr(int cmd_num, int opt, int opterr)
{
assert(cmd_num >= CMD_MIN && cmd_num <= CMD_MAX);
case ':':
die("option '-%c' requires a value\n%s\n%s", opt,
command_usage(cmd_num), command_help_text(cmd_num));
break;
case '?':
default:
die("unrecognized option '-%c'\nUsage: %s\n%s", opt,
command_usage(cmd_num), command_help_text(cmd_num));
break;
}
}
Anurag
> do you have example output from a prototype to help me understand
> what you have in mind?
_______________________________________________
networking-discuss mailing list
[email protected]