Sfoglia il codice sorgente

[parseopt] Refer to online documentation for command help

The online documentation (e.g. http://ipxe.org/cmd/ifopen), though not
yet complete, is far more comprehensive than could be provided within
the iPXE binary.  Save around 200 bytes (compressed) by removing the
command descriptions from the interactive help, and instead referring
users directly to the web page describing the relevant command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 anni fa
parent
commit
7d5dcc9299

+ 2
- 3
src/arch/i386/hci/commands/pxe_cmd.c Vedi File

@@ -33,7 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 /** "startpxe" command descriptor */
34 34
 static struct command_descriptor startpxe_cmd =
35 35
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
36
-		       "[<interface>]", "" );
36
+		       "[<interface>]" );
37 37
 
38 38
 /**
39 39
  * "startpxe" payload
@@ -68,8 +68,7 @@ static struct option_descriptor stoppxe_opts[] = {};
68 68
 
69 69
 /** "stoppxe" command descriptor */
70 70
 static struct command_descriptor stoppxe_cmd =
71
-	COMMAND_DESC ( struct stoppxe_options, stoppxe_opts, 0, 0,
72
-		       "", "" );
71
+	COMMAND_DESC ( struct stoppxe_options, stoppxe_opts, 0, 0, "" );
73 72
 
74 73
 /**
75 74
  * The "stoppxe" command

+ 1
- 1
src/arch/i386/hci/commands/reboot_cmd.c Vedi File

@@ -36,7 +36,7 @@ static struct option_descriptor reboot_opts[] = {};
36 36
 
37 37
 /** "reboot" command descriptor */
38 38
 static struct command_descriptor reboot_cmd =
39
-	COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, "", "" );
39
+	COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, "" );
40 40
 
41 41
 /**
42 42
  * The "reboot" command

+ 2
- 3
src/core/exec.c Vedi File

@@ -298,8 +298,7 @@ static struct option_descriptor exit_opts[] = {};
298 298
 
299 299
 /** "exit" command descriptor */
300 300
 static struct command_descriptor exit_cmd =
301
-	COMMAND_DESC ( struct exit_options, exit_opts, 0, 1,
302
-		       "[<status>]", "" );
301
+	COMMAND_DESC ( struct exit_options, exit_opts, 0, 1, "[<status>]" );
303 302
 
304 303
 /**
305 304
  * "exit" command
@@ -344,7 +343,7 @@ static struct option_descriptor isset_opts[] = {};
344 343
 /** "isset" command descriptor */
345 344
 static struct command_descriptor isset_cmd =
346 345
 	COMMAND_DESC ( struct isset_options, isset_opts, 0, MAX_ARGUMENTS,
347
-		       "[...]", "" );
346
+		       "[...]" );
348 347
 
349 348
 /**
350 349
  * "isset" command

+ 2
- 1
src/core/parseopt.c Vedi File

@@ -132,7 +132,8 @@ int parse_image ( const char *text, struct image **image ) {
132 132
  * @v argv		Argument list
133 133
  */
134 134
 void print_usage ( struct command_descriptor *cmd, char **argv ) {
135
-	printf ( "Usage:\n\n  %s %s\n", argv[0], cmd->usage_description );
135
+	printf ( "Usage:\n\n  %s %s\n\nSee http://ipxe.org/cmd/%s for further "
136
+		 "information\n", argv[0], cmd->usage, argv[0] );
136 137
 }
137 138
 
138 139
 /**

+ 1
- 1
src/hci/commands/autoboot_cmd.c Vedi File

@@ -35,7 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
35 35
 /** "autoboot" command descriptor */
36 36
 static struct command_descriptor autoboot_cmd =
37 37
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
38
-		       "[<interface>...]", "Attempt to boot the system" );
38
+		       "[<interface>...]" );
39 39
 
40 40
 /**
41 41
  * "autoboot" command

+ 1
- 3
src/hci/commands/config_cmd.c Vedi File

@@ -41,9 +41,7 @@ static struct option_descriptor config_opts[] = {};
41 41
 
42 42
 /** "config" command descriptor */
43 43
 static struct command_descriptor config_cmd =
44
-	COMMAND_DESC ( struct config_options, config_opts, 0, 1,
45
-		       "[<scope>]",
46
-		       "Open the option configuration console" );
44
+	COMMAND_DESC ( struct config_options, config_opts, 0, 1, "[<scope>]" );
47 45
 
48 46
 /**
49 47
  * Parse settings scope name

+ 2
- 4
src/hci/commands/dhcp_cmd.c Vedi File

@@ -43,8 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
43 43
 /** "dhcp" command descriptor */
44 44
 static struct command_descriptor dhcp_cmd =
45 45
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
46
-		       "[<interface>] [<interface>...]",
47
-		       "Configure network interface(s) using DHCP" );
46
+		       "[<interface>...]" );
48 47
 
49 48
 /**
50 49
  * Execute "dhcp" command for a network device
@@ -88,8 +87,7 @@ static struct option_descriptor pxebs_opts[] = {};
88 87
 /** "pxebs" command descriptor */
89 88
 static struct command_descriptor pxebs_cmd =
90 89
 	COMMAND_DESC ( struct pxebs_options, pxebs_opts, 2, 2,
91
-		       "<interface> <server_type>",
92
-		       "Perform PXE Boot Server discovery" );
90
+		       "<interface> <server type>" );
93 91
 
94 92
 /**
95 93
  * The "pxebs" command

+ 1
- 2
src/hci/commands/digest_cmd.c Vedi File

@@ -44,8 +44,7 @@ static struct option_descriptor digest_opts[] = {};
44 44
 /** "digest" command descriptor */
45 45
 static struct command_descriptor digest_cmd =
46 46
 	COMMAND_DESC ( struct digest_options, digest_opts, 1, MAX_ARGUMENTS,
47
-		       "<image> [<image>...]",
48
-		       "Calculate the digest of an image" );
47
+		       "<image> [<image>...]" );
49 48
 
50 49
 /**
51 50
  * The "digest" command

+ 2
- 3
src/hci/commands/fcmgmt_cmd.c Vedi File

@@ -106,8 +106,7 @@ static struct option_descriptor fcstat_opts[] = {};
106 106
 
107 107
 /** "fcstat" command descriptor */
108 108
 static struct command_descriptor fcstat_cmd =
109
-	COMMAND_DESC ( struct fcstat_options, fcstat_opts, 0, 0,
110
-		       "", "" );
109
+	COMMAND_DESC ( struct fcstat_options, fcstat_opts, 0, 0, "" );
111 110
 
112 111
 /**
113 112
  * The "fcstat" command
@@ -153,7 +152,7 @@ static struct option_descriptor fcels_opts[] = {
153 152
 /** "fcels" command descriptor */
154 153
 static struct command_descriptor fcels_cmd =
155 154
 	COMMAND_DESC ( struct fcels_options, fcels_opts, 1, 1,
156
-		       "[--port <port>] [--id <peer_port_id>] <command>", "" );
155
+		       "[--port <port>] [--id <peer port id>] <request>" );
157 156
 
158 157
 /**
159 158
  * The "fcels" command

+ 1
- 6
src/hci/commands/gdbstub_cmd.c Vedi File

@@ -65,12 +65,7 @@ static struct option_descriptor gdbstub_opts[] = {};
65 65
 /** "gdbstub" command descriptor */
66 66
 static struct command_descriptor gdbstub_cmd =
67 67
 	COMMAND_DESC ( struct gdbstub_options, gdbstub_opts, 1, MAX_ARGUMENTS,
68
-		       "<transport> [<options>...]",
69
-		       "Start remote debugging using one of the following "
70
-		       "transports:\n"
71
-		       "  serial           use serial port (if compiled in)\n"
72
-		       "  udp <interface>  use UDP over network interface "
73
-		       "(if compiled in)" );
68
+		       "<transport> [<options>...]" );
74 69
 
75 70
 /**
76 71
  * The "gdbstub" command

+ 3
- 6
src/hci/commands/ifmgmt_cmd.c Vedi File

@@ -87,8 +87,7 @@ int ifcommon_exec ( int argc, char **argv,
87 87
 /** "ifopen" command descriptor */
88 88
 static struct command_descriptor ifopen_cmd =
89 89
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
90
-		       "[<interface>...]",
91
-		       "Open network interface(s)" );
90
+		       "[<interface>...]" );
92 91
 
93 92
 /**
94 93
  * "ifopen" payload
@@ -114,8 +113,7 @@ static int ifopen_exec ( int argc, char **argv ) {
114 113
 /** "ifclose" command descriptor */
115 114
 static struct command_descriptor ifclose_cmd =
116 115
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
117
-		       "[<interface>...]",
118
-		       "Close network interface(s)" );
116
+		       "[<interface>...]" );
119 117
 
120 118
 /**
121 119
  * "ifclose" payload
@@ -142,8 +140,7 @@ static int ifclose_exec ( int argc, char **argv ) {
142 140
 /** "ifstat" command descriptor */
143 141
 static struct command_descriptor ifstat_cmd =
144 142
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
145
-		       "[<interface>...]",
146
-		       "Show network interface(s)" );
143
+		       "[<interface>...]" );
147 144
 
148 145
 /**
149 146
  * "ifstat" payload

+ 8
- 14
src/hci/commands/image_cmd.c Vedi File

@@ -84,20 +84,17 @@ static struct option_descriptor imgfetch_opts[] = {
84 84
 /** "imgfetch" command descriptor */
85 85
 static struct command_descriptor imgfetch_cmd =
86 86
 	COMMAND_DESC ( struct imgfetch_options, imgfetch_opts, 1, MAX_ARGUMENTS,
87
-		       "[--name <name>] <image_url> [<arguments>...]",
88
-		       "Fetch image" );
87
+		       "[--name <name>] <uri> [<arguments>...]" );
89 88
 
90 89
 /** "kernel" command descriptor */
91 90
 static struct command_descriptor kernel_cmd =
92 91
 	COMMAND_DESC ( struct imgfetch_options, imgfetch_opts, 1, MAX_ARGUMENTS,
93
-		       "[--name <name>] <image_url> [<arguments>...]",
94
-		       "Fetch and load image" );
92
+		       "[--name <name>] <uri> [<arguments>...]" );
95 93
 
96 94
 /** "chain" command descriptor */
97 95
 static struct command_descriptor chain_cmd =
98 96
 	COMMAND_DESC ( struct imgfetch_options, imgfetch_opts, 1, MAX_ARGUMENTS,
99
-		       "[--name <name>] <image_url> [<arguments>...]",
100
-		       "Fetch and execute image" );
97
+		       "[--name <name>] <uri> [<arguments>...]" );
101 98
 
102 99
 /**
103 100
  * The "imgfetch" and friends command body
@@ -200,8 +197,7 @@ static struct option_descriptor imgload_opts[] = {};
200 197
 
201 198
 /** "imgload" command descriptor */
202 199
 static struct command_descriptor imgload_cmd =
203
-	COMMAND_DESC ( struct imgload_options, imgload_opts, 1, 1,
204
-		       "<image>", "Load image" );
200
+	COMMAND_DESC ( struct imgload_options, imgload_opts, 1, 1, "<image>" );
205 201
 
206 202
 /**
207 203
  * The "imgload" command
@@ -242,8 +238,7 @@ static struct option_descriptor imgargs_opts[] = {};
242 238
 /** "imgargs" command descriptor */
243 239
 static struct command_descriptor imgargs_cmd =
244 240
 	COMMAND_DESC ( struct imgargs_options, imgargs_opts, 1, MAX_ARGUMENTS,
245
-		       "<image> [<arguments>...]",
246
-		       "Set arguments for image" );
241
+		       "<image> [<arguments>...]" );
247 242
 
248 243
 /**
249 244
  * The "imgargs" command body
@@ -282,7 +277,7 @@ static struct option_descriptor imgexec_opts[] = {};
282 277
 /** "imgexec" command descriptor */
283 278
 static struct command_descriptor imgexec_cmd =
284 279
 	COMMAND_DESC ( struct imgexec_options, imgexec_opts, 0, 1,
285
-		       "[<image>]", "Execute image" );
280
+		       "[<image>]" );
286 281
 
287 282
 /**
288 283
  * The "imgexec" command
@@ -330,8 +325,7 @@ static struct option_descriptor imgstat_opts[] = {};
330 325
 
331 326
 /** "imgstat" command descriptor */
332 327
 static struct command_descriptor imgstat_cmd =
333
-	COMMAND_DESC ( struct imgstat_options, imgstat_opts, 0, 0,
334
-		       "", "List images" );
328
+	COMMAND_DESC ( struct imgstat_options, imgstat_opts, 0, 0, "" );
335 329
 
336 330
 /**
337 331
  * The "imgstat" command
@@ -366,7 +360,7 @@ static struct option_descriptor imgfree_opts[] = {};
366 360
 /** "imgfree" command descriptor */
367 361
 static struct command_descriptor imgfree_cmd =
368 362
 	COMMAND_DESC ( struct imgfree_options, imgfree_opts, 0, 1,
369
-		       "[<image>]", "Free image(s)" );
363
+		       "[<image>]" );
370 364
 
371 365
 /**
372 366
  * The "imgfree" command

+ 2
- 4
src/hci/commands/iwmgmt_cmd.c Vedi File

@@ -34,8 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
34 34
 /** "iwstat" command descriptor */
35 35
 static struct command_descriptor iwstat_cmd =
36 36
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
37
-		       "[<interface>...]",
38
-		       "Show wireless interface(s)" );
37
+		       "[<interface>...]" );
39 38
 
40 39
 /**
41 40
  * "iwstat" payload
@@ -66,8 +65,7 @@ static int iwstat_exec ( int argc, char **argv ) {
66 65
 /** "iwlist" command descriptor */
67 66
 static struct command_descriptor iwlist_cmd =
68 67
 	COMMAND_DESC ( struct ifcommon_options, ifcommon_opts, 0, MAX_ARGUMENTS,
69
-		       "[<interface>...]",
70
-		       "List wireless networks" );
68
+		       "[<interface>...]" );
71 69
 
72 70
 /**
73 71
  * "iwlist" payload

+ 1
- 2
src/hci/commands/login_cmd.c Vedi File

@@ -38,8 +38,7 @@ static struct option_descriptor login_opts[] = {};
38 38
 
39 39
 /** "login" command descriptor */
40 40
 static struct command_descriptor login_cmd =
41
-	COMMAND_DESC ( struct login_options, login_opts, 0, 0,
42
-		       "", "Prompt for login credentials" );
41
+	COMMAND_DESC ( struct login_options, login_opts, 0, 0, "" );
43 42
 
44 43
 /**
45 44
  * "login" command

+ 2
- 2
src/hci/commands/lotest_cmd.c Vedi File

@@ -49,8 +49,8 @@ static struct option_descriptor lotest_opts[] = {
49 49
 /** "lotest" command descriptor */
50 50
 static struct command_descriptor lotest_cmd =
51 51
 	COMMAND_DESC ( struct lotest_options, lotest_opts, 2, 2,
52
-		       "[--mtu <mtu>] <sending_interface> "
53
-		       "<receiving_interface>", "" );
52
+		       "[--mtu <mtu>] <sending interface> "
53
+		       "<receiving interface>" );
54 54
 
55 55
 /**
56 56
  * "lotest" command

+ 3
- 5
src/hci/commands/nvo_cmd.c Vedi File

@@ -42,8 +42,7 @@ static struct option_descriptor show_opts[] = {};
42 42
 
43 43
 /** "show" command descriptor */
44 44
 static struct command_descriptor show_cmd =
45
-	COMMAND_DESC ( struct show_options, show_opts, 1, 1,
46
-		       "<setting>", "" );
45
+	COMMAND_DESC ( struct show_options, show_opts, 1, 1, "<setting>" );
47 46
 
48 47
 /**
49 48
  * "show" command
@@ -88,7 +87,7 @@ static struct option_descriptor set_opts[] = {};
88 87
 /** "set" command descriptor */
89 88
 static struct command_descriptor set_cmd =
90 89
 	COMMAND_DESC ( struct set_options, set_opts, 1, MAX_ARGUMENTS,
91
-		       "<setting> <value>", "" );
90
+		       "<setting> <value>" );
92 91
 
93 92
 /**
94 93
  * "set" command
@@ -146,8 +145,7 @@ static struct option_descriptor clear_opts[] = {};
146 145
 
147 146
 /** "clear" command descriptor */
148 147
 static struct command_descriptor clear_cmd =
149
-	COMMAND_DESC ( struct clear_options, clear_opts, 1, 1,
150
-		       "<setting>", "" );
148
+	COMMAND_DESC ( struct clear_options, clear_opts, 1, 1, "<setting>" );
151 149
 
152 150
 /**
153 151
  * "clear" command

+ 1
- 2
src/hci/commands/route_cmd.c Vedi File

@@ -38,8 +38,7 @@ static struct option_descriptor route_opts[] = {};
38 38
 
39 39
 /** "route" command descriptor */
40 40
 static struct command_descriptor route_cmd =
41
-	COMMAND_DESC ( struct route_options, route_opts, 0, 0,
42
-		       "", "Display the routing table" );
41
+	COMMAND_DESC ( struct route_options, route_opts, 0, 0, "" );
43 42
 
44 43
 /**
45 44
  * The "route" command

+ 1
- 1
src/hci/commands/sanboot_cmd.c Vedi File

@@ -42,7 +42,7 @@ static struct option_descriptor sanboot_opts[] = {};
42 42
 /** "sanboot" command descriptor */
43 43
 static struct command_descriptor sanboot_cmd =
44 44
 	COMMAND_DESC ( struct sanboot_options, sanboot_opts, 1, 1,
45
-		       "<root-path>", "Boot from SAN target" );
45
+		       "<root-path>" );
46 46
 
47 47
 /**
48 48
  * The "sanboot" command

+ 2
- 3
src/hci/commands/time_cmd.c Vedi File

@@ -45,7 +45,7 @@ static struct option_descriptor time_opts[] = {};
45 45
 /** "time" command descriptor */
46 46
 static struct command_descriptor time_cmd =
47 47
 	COMMAND_DESC ( struct time_options, time_opts, 1, MAX_ARGUMENTS,
48
-		       "<command>", "Time a command" );
48
+		       "<command>" );
49 49
 
50 50
 /**
51 51
  * "time" command
@@ -87,8 +87,7 @@ static struct option_descriptor sleep_opts[] = {};
87 87
 
88 88
 /** "sleep" command descriptor */
89 89
 static struct command_descriptor sleep_cmd =
90
-	COMMAND_DESC ( struct sleep_options, sleep_opts, 1, 1,
91
-		       "<seconds>", "Sleep for <seconds> seconds" );
90
+	COMMAND_DESC ( struct sleep_options, sleep_opts, 1, 1, "<seconds>" );
92 91
 
93 92
 /**
94 93
  * "sleep" command

+ 2
- 4
src/hci/commands/vlan_cmd.c Vedi File

@@ -53,8 +53,7 @@ static struct option_descriptor vcreate_opts[] = {
53 53
 static struct command_descriptor vcreate_cmd =
54 54
 	COMMAND_DESC ( struct vcreate_options, vcreate_opts, 1, 1,
55 55
 		       "--tag <tag> [--priority <priority>] "
56
-		       "<trunk interface>",
57
-		       "Create a VLAN interface" );
56
+		       "<trunk interface>" );
58 57
 
59 58
 /**
60 59
  * "vcreate" command
@@ -95,8 +94,7 @@ static struct option_descriptor vdestroy_opts[] = {};
95 94
 /** "vdestroy" command descriptor */
96 95
 static struct command_descriptor vdestroy_cmd =
97 96
 	COMMAND_DESC ( struct vdestroy_options, vdestroy_opts, 1, 1,
98
-		       "<VLAN interface>",
99
-		       "Destroy a VLAN interface" );
97
+		       "<VLAN interface>" );
100 98
 
101 99
 /**
102 100
  * "vdestroy" command

+ 1
- 2
src/hci/shell.c Vedi File

@@ -97,8 +97,7 @@ static struct option_descriptor shell_opts[] = {};
97 97
 
98 98
 /** "shell" command descriptor */
99 99
 static struct command_descriptor shell_cmd =
100
-	COMMAND_DESC ( struct shell_options, shell_opts, 0, 0,
101
-		       "", "" );
100
+	COMMAND_DESC ( struct shell_options, shell_opts, 0, 0, "" );
102 101
 
103 102
 /**
104 103
  * "shell" command

+ 1
- 2
src/image/script.c Vedi File

@@ -218,8 +218,7 @@ static struct option_descriptor goto_opts[] = {};
218 218
 
219 219
 /** "goto" command descriptor */
220 220
 static struct command_descriptor goto_cmd =
221
-	COMMAND_DESC ( struct goto_options, goto_opts, 1, 1,
222
-		       "<label>", "" );
221
+	COMMAND_DESC ( struct goto_options, goto_opts, 1, 1, "<label>" );
223 222
 
224 223
 /**
225 224
  * Current "goto" label

+ 4
- 6
src/include/ipxe/parseopt.h Vedi File

@@ -81,12 +81,12 @@ struct command_descriptor {
81 81
 	uint8_t min_args;
82 82
 	/** Maximum number of non-option arguments */
83 83
 	uint8_t max_args;
84
-	/** Command usage and description
84
+	/** Command usage
85 85
 	 *
86 86
 	 * This excludes the literal "Usage:" and the command name,
87 87
 	 * which will be prepended automatically.
88 88
 	 */
89
-	const char *usage_description;
89
+	const char *usage;
90 90
 };
91 91
 
92 92
 /** No maximum number of arguments */
@@ -99,11 +99,9 @@ struct command_descriptor {
99 99
  * @v _options		Option descriptor array
100 100
  * @v _check_args	Remaining argument checker
101 101
  * @v _usage		Command usage
102
- * @v _description	Command description
103 102
  * @ret _command	Command descriptor
104 103
  */
105
-#define COMMAND_DESC( _struct, _options, _min_args, _max_args, _usage,	      \
106
-		      _description )					      \
104
+#define COMMAND_DESC( _struct, _options, _min_args, _max_args, _usage )	      \
107 105
 	{								      \
108 106
 		.options = ( ( ( ( typeof ( _options[0] ) * ) NULL ) ==	      \
109 107
 			       ( ( struct option_descriptor * ) NULL ) ) ?    \
@@ -113,7 +111,7 @@ struct command_descriptor {
113 111
 		.len = sizeof ( _struct ),				      \
114 112
 		.min_args = _min_args,					      \
115 113
 		.max_args = _max_args,					      \
116
-		.usage_description = _usage "\n\n" _description,	      \
114
+		.usage = _usage,					      \
117 115
 	 }
118 116
 
119 117
 extern int parse_string ( const char *text, const char **value );

Loading…
Annulla
Salva