-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to append the command after arugment? #97
Comments
Hello! You can dispatch it only with very hard validation callback on #define MODE_CONFIG_VLAN 0x02
struct vlan_context {
// Add all fields that you need for vlan
};
int config_vlan(struct cli_def *cli, const char *command, char *argv[], int argc);
void initialize_commands(struct cli_def *cli) {
struct cli_def *c;
c = cli_register_command(cli, NULL, "vlan", config_vlan, PRIVILEGE_PRIVILEGED, MODE_CONFIG,
"Configure VLAN");
c = cli_register_command(cli, c, "ip", NULL, PRIVILEGE_PRIVILEGED, MODE_CONFIG, "ip help");
c = cli_register_command(cli, c, "igmp", NULL, PRIVILEGE_PRIVILEGED, MODE_CONFIG,
"igmp help");
c = cli_register_command(cli, c, "snooping", NULL, PRIVILEGE_PRIVILEGED, MODE_CONFIG,
"snooping help");
c = cli_register_command(cli, c, "mrouter", NULL, PRIVILEGE_PRIVILEGED, MODE_CONFIG_VLAN,
"mrouter help");
c = cli_register_command(cli, c, "interfaces", NULL, PRIVILEGE_PRIVILEGED, MODE_CONFIG_VLAN,
"interfaces help");
}
int config_vlan(struct cli_def *cli, const char *command, char *argv[], int argc) {
static struct vlan_context ctx;
// Your validation routine, if no argument should be use -- set default vlan id
...
// If all is ok
cli_set_context(cli, (void *)&ctx);
cli_set_configmode(cli, MODE_CONFIG_VLAN, "vlan");
} And than you can config it as your_proj> enable
your_proj# configure terminal
your_proj(config)# vlan 12
your_proj(config-vlan)# ip igmp snooping mrouter interfaces <INTERFACE-LIST> For my opinion this would be much easier, than when you would write |
Thanks for your reply, @filka55533. it is a good opinion. Unfortunately, we don't want to modify the CLI command hierarchy. So, regarding question 2, is there any way to solve it? |
Just look on example with |
Hi there!
stuck in the following situations...
example:
example:
I would appreciate any feedback! Thank you!
The text was updated successfully, but these errors were encountered: