@@ -4,70 +4,65 @@ use menu::*;
44use pancurses:: { endwin, initscr, noecho, Input } ;
55use std:: fmt:: Write ;
66
7- const FOO_ITEM : Item < Output > = Item {
8- item_type : ItemType :: Callback {
9- function : select_foo,
10- parameters : & [
11- Parameter :: Mandatory ( "a" ) ,
12- Parameter :: Optional ( "b" ) ,
13- Parameter :: Named ( "verbose" ) ,
14- Parameter :: NamedValue {
15- parameter_name : "level" ,
16- argument_name : "INT" ,
17- } ,
18- ] ,
19- } ,
20- command : "foo" ,
21- help : Some ( "makes a foo appear" ) ,
22- } ;
23-
24- const BAR_ITEM : Item < Output > = Item {
25- item_type : ItemType :: Callback {
26- function : select_bar,
27- parameters : & [ ] ,
28- } ,
29- command : "bar" ,
30- help : Some ( "fandoggles a bar" ) ,
31- } ;
32-
33- const ENTER_ITEM : Item < Output > = Item {
34- item_type : ItemType :: Menu ( & SUB_MENU ) ,
35- command : "sub" ,
36- help : Some ( "enter sub-menu" ) ,
37- } ;
38-
397const ROOT_MENU : Menu < Output > = Menu {
408 label : "root" ,
41- items : & [ & FOO_ITEM , & BAR_ITEM , & ENTER_ITEM ] ,
9+ items : & [
10+ & Item {
11+ item_type : ItemType :: Callback {
12+ function : select_foo,
13+ parameters : & [
14+ Parameter :: Mandatory ( "a" ) ,
15+ Parameter :: Optional ( "b" ) ,
16+ Parameter :: Named ( "verbose" ) ,
17+ Parameter :: NamedValue {
18+ parameter_name : "level" ,
19+ argument_name : "INT" ,
20+ } ,
21+ ] ,
22+ } ,
23+ command : "foo" ,
24+ help : Some ( "makes a foo appear" ) ,
25+ } ,
26+ & Item {
27+ item_type : ItemType :: Callback {
28+ function : select_bar,
29+ parameters : & [ ] ,
30+ } ,
31+ command : "bar" ,
32+ help : Some ( "fandoggles a bar" ) ,
33+ } ,
34+ & Item {
35+ item_type : ItemType :: Menu ( & Menu {
36+ label : "sub" ,
37+ items : & [
38+ & Item {
39+ item_type : ItemType :: Callback {
40+ function : select_baz,
41+ parameters : & [ ] ,
42+ } ,
43+ command : "baz" ,
44+ help : Some ( "thingamobob a baz" ) ,
45+ } ,
46+ & Item {
47+ item_type : ItemType :: Callback {
48+ function : select_quux,
49+ parameters : & [ ] ,
50+ } ,
51+ command : "quux" ,
52+ help : Some ( "maximum quux" ) ,
53+ } ,
54+ ] ,
55+ entry : Some ( enter_sub) ,
56+ exit : Some ( exit_sub) ,
57+ } ) ,
58+ command : "sub" ,
59+ help : Some ( "enter sub-menu" ) ,
60+ } ,
61+ ] ,
4262 entry : Some ( enter_root) ,
4363 exit : Some ( exit_root) ,
4464} ;
4565
46- const BAZ_ITEM : Item < Output > = Item {
47- item_type : ItemType :: Callback {
48- function : select_baz,
49- parameters : & [ ] ,
50- } ,
51- command : "baz" ,
52- help : Some ( "thingamobob a baz" ) ,
53- } ;
54-
55- const QUUX_ITEM : Item < Output > = Item {
56- item_type : ItemType :: Callback {
57- function : select_quux,
58- parameters : & [ ] ,
59- } ,
60- command : "quux" ,
61- help : Some ( "maximum quux" ) ,
62- } ;
63-
64- const SUB_MENU : Menu < Output > = Menu {
65- label : "sub" ,
66- items : & [ & BAZ_ITEM , & QUUX_ITEM ] ,
67- entry : Some ( enter_sub) ,
68- exit : Some ( exit_sub) ,
69- } ;
70-
7166struct Output ( pancurses:: Window ) ;
7267
7368impl std:: fmt:: Write for Output {
0 commit comments