Menu/cmd: add sub menu entry command support
this will simplify the creation of navigation link
as this
menu -a -m boot -d "Boot Menu"
menu -a -m network -d "Network settings"
menu -e -a -m network -u boot -d "Back"
menu -e -a -m boot -u network -d "Network settings ->"
menu -e -a -m boot -c reset -R -d "Reset"
menu -e -a -m boot -c clear -d "Exit"
menu -s -m boot
in C
struct menu m_boot = {
.name = "boot",
.display = "Boot Menu",
};
struct menu m_network = {
.name = "network",
.display = "Network settings",
};
struct menu_entry e_to_network = {
.display = "Network settings ->",
.action = menu_action_show,
.priv = &m_network,
};
struct menu_entry e_to_boot = {
.display = "Back",
.action = menu_action_show,
.priv = &m_boot,
};
struct menu_entry e_reset = {
.display = "Reset",
.action = menu_action_run,
.priv = "reset",
};
struct menu_entry e_exit = {
.display = "Exit",
.action = menu_action_run,
.non_re_ent = 1,
.priv = "clear",
};
void menu_test(void)
{
menu_add(&m_boot);
menu_add(&m_network);
menu_add_entry(&m_boot, &e_to_network);
menu_add_entry(&m_boot, &e_reset);
menu_add_entry(&m_boot, &e_exit);
menu_add_entry(&m_network, &e_to_boot);
menu_show(&m_boot);
}
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>