@@ -230,38 +230,38 @@ of their Python name. Options do not have a short name by default.
230230Option names can be controlled by prefixing their description with a value in square brackets ` [] ` :
231231
232232* ` [-t] ` &rightarrow ; ` -t ` is the short name
233+ * ` [--to] ` &rightarrow ; ` --to ` is the long name
233234* ` [-t/--to] ` &rightarrow ; ` -t ` is the short name and ` --to ` is the long name
235+ * ` [-t/] ` &rightarrow ; ` -t ` is the short name, the long name is * removed* .
234236
235237<div align =" right " class =" code-source " ><sub >
236238 <a href="https://github.com/treykeown/arguably/blob/main/etc/scripts/hello-6.py">[source]</a>
237239</sub ></div >
238240
239241``` python
240242@arguably.command
241- def hello (* from_ , name = " world" ):
243+ def hello (* , from_ = " me " , name = " world" ):
242244 """
243245 this will say hello to someone
244246
245247 Args:
246- from_: greetings are sent from these people
247- name: [-t/--to] is who this will greet
248+ from_: [-f/] the sender of these greetings
249+ name: [-t/--to] the receiver of these greetings
248250 """
249251 print (f " Hello, { name} ! " )
250- print (f " From: { ' , ' .join( from_) } " )
252+ print (f " From: { from_} " )
251253```
252254
253255``` console
254- user@machine:~ $ python3 hello-6.py -h
255- usage: hello-6.py [-h] [-t TO ] [from ... ]
256+ user@machine:~ $ python3 etc/scripts/ hello-6.py -h
257+ usage: hello-6.py [-h] [-f FROM ] [-t TO ]
256258
257259this will say hello to someone
258260
259- positional arguments:
260- from greetings are sent from these people (type: str)
261-
262261options:
263262 -h, --help show this help message and exit
264- -t, --to TO is who this will greet (type: str, default: world)
263+ -f FROM the sender of these greetings (type: str, default: me)
264+ -t, --to TO the receiver of these greetings (type: str, default: world)
265265```
266266
267267### Metavars
@@ -282,37 +282,35 @@ tuple length.
282282
283283``` python
284284@arguably.command
285- def hello (* from_ , name = " world" ):
285+ def hello (* , from_ = " me " , name = " world" ):
286286 """
287287 this will say hello to someone
288288
289289 Args:
290- from_: greetings are sent from these people
291- name: [-t/--to] is {who} this will greet
290+ from_: [-f/] the {sender} of these greetings
291+ name: [-t/--to] the {receiver} of these greetings
292292 """
293293 print (f " Hello, { name} ! " )
294- print (f " From: { ' , ' .join( from_) } " )
294+ print (f " From: { from_} " )
295295```
296296
297297``` console
298- user@machine:~ $ python3 hello-7.py -h
299- usage: hello-7.py [-h] [-t WHO ] [from ... ]
298+ user@machine:~ $ python3 etc/scripts/ hello-7.py -h
299+ usage: hello-7.py [-h] [-f SENDER ] [-t RECEIVER ]
300300
301301this will say hello to someone
302302
303- positional arguments:
304- from greetings are sent from these people (type: str)
305-
306303options:
307- -h, --help show this help message and exit
308- -t, --to WHO is who this will greet (type: str, default: world)
304+ -h, --help show this help message and exit
305+ -f SENDER the sender of these greetings (type: str, default: me)
306+ -t, --to RECEIVER the receiver of these greetings (type: str, default: world)
309307```
310308
311309Compare the last line with how it was before:
312310
313311``` console
314- Before: -t, --to TO is who this will greet (type: str, default: world)
315- After: -t, --to WHO is who this will greet (type: str, default: world)
312+ Before: -t, --to TO the receiver of these greetings (type: str, default: world)
313+ After: -t, --to RECEIVER the receiver of these greetings (type: str, default: world)
316314```
317315
318316## Summary
@@ -340,5 +338,9 @@ usage: intro.py [-h] [-x OPTION] required [not-required] [others ...]
340338
341339Docstrings are used for command and argument help messages. They can also:
342340
343- * Change the short (` -n ` ) and long name (` --name ` ) of an ` --option ` by prefixing its description with ` [-n/--name] `
341+ * Change option names:
342+ * Set the short name with ` [-n] `
343+ * Change the long name with ` [--name] `
344+ * Set the short and long names with ` [-n/--name] `
345+ * Set the short name and remove the long name with ` [-n/] `
344346* Change the metavar of an argument to ` SOMETHING ` by wrapping a word in curly braces: ` {something} `
0 commit comments