[syslinux] ROSH: bug or feature
Pierre-Alexandre Meyer
pierre at mouraf.org
Tue Mar 24 15:50:31 PDT 2009
On Tuesday 24 March 2009 à 11:22:43PM, Pierre-Alexandre Meyer wrote:
> FWIW, we have been working with Erwan to improve the CLI of hdt. The new
> version will be merged post 3.74 release but you can have a look at my
> staging tree:
>
> http://git.zytor.com/?p=users/pam/hdt-pierre.git;a=shortlog;h=refs/heads/for-erwan
A code snippet is worth...
Let's say you want to implement your own mode (let's call it gene):
$ set mode gene
... entering mode "gene" ...
$ show arg1 arg2
--> will execute do_something_not_too_crazy(arc, argv)
$ show crazy arg1 arg2
--> will execute do_something_crazy(arc, argv)
$ show crazy2 arg1 arg2
--> will execute do_something_crazy2(arc, argv)
Note: "crazy" is an example of a "module" I was talking about.
You only need to implement the following structures:
struct cli_callback_descr list_gene_modules[] = {
{
.name = "crazy",
.exec = do_something_crazy,
},
{
.name = "crazy2",
.exec = do_something_crazy2,
},
};
struct cli_module_descr show_modules = {
.modules = list_gene_modules,
.nb_modules = 2,
.default_callback = do_something_not_too_crazy,
};
struct cli_mode_descr gene_mode = {
.mode = "gene",
.show_modules = &show_modules,
};
The core will do the rest (and generate the help displaying available
functions, exit to quit this mode, ...).
The "show" command is something we use a lot in hdt, but you can imagine
whatever you want (ls, mkdir, ...).
--
Pierre-Alexandre Meyer
More information about the Syslinux
mailing list