Skip to main content
Code Review

Return to Question

(Cmd) help
Documented commands (type help <topic>):
========================================
help test1 test2
(Cmd) help
Documented commands (type help <topic>):
========================================
help test1 test2
(Cmd) help test1
usage: test1 [-h] [--foo FOO]
optional arguments:
 -h, --help show this help message and exit
 --foo FOO foo help
(Cmd) test2 -h
usage: test2 [-h] [--bar BAR]
optional arguments:
 -h, --help show this help message and exit
 --bar BAR bar help
(Cmd) help test1
usage: test1 [-h] [--foo FOO]
optional arguments:
 -h, --help show this help message and exit
 --foo FOO foo help
(Cmd) test2 -h
usage: test2 [-h] [--bar BAR]
optional arguments:
 -h, --help show this help message and exit
 --bar BAR bar help
(Cmd) test1 --unk
usage: test1 [-h] [--foo FOO]
test1: error: unrecognized arguments: --unk
(Cmd)
(Cmd) test1 --unk
usage: test1 [-h] [--foo FOO]
test1: error: unrecognized arguments: --unk
(Cmd)
(Cmd) help
Documented commands (type help <topic>):
========================================
help test1 test2
(Cmd) help test1
usage: test1 [-h] [--foo FOO]
optional arguments:
 -h, --help show this help message and exit
 --foo FOO foo help
(Cmd) test2 -h
usage: test2 [-h] [--bar BAR]
optional arguments:
 -h, --help show this help message and exit
 --bar BAR bar help
(Cmd) test1 --unk
usage: test1 [-h] [--foo FOO]
test1: error: unrecognized arguments: --unk
(Cmd)
(Cmd) help
Documented commands (type help <topic>):
========================================
help test1 test2
(Cmd) help test1
usage: test1 [-h] [--foo FOO]
optional arguments:
 -h, --help show this help message and exit
 --foo FOO foo help
(Cmd) test2 -h
usage: test2 [-h] [--bar BAR]
optional arguments:
 -h, --help show this help message and exit
 --bar BAR bar help
(Cmd) test1 --unk
usage: test1 [-h] [--foo FOO]
test1: error: unrecognized arguments: --unk
(Cmd)
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I looked around for solutions and found this this. However, that solution relinquishes cmd's listing of available functions, and its help functionality. As well, it requires that all the available commands and their arguments be listed in one place (i.e. __init__), which makes it impractical when there are many commands.

I looked around for solutions and found this. However, that solution relinquishes cmd's listing of available functions, and its help functionality. As well, it requires that all the available commands and their arguments be listed in one place (i.e. __init__), which makes it impractical when there are many commands.

I looked around for solutions and found this. However, that solution relinquishes cmd's listing of available functions, and its help functionality. As well, it requires that all the available commands and their arguments be listed in one place (i.e. __init__), which makes it impractical when there are many commands.

Tweeted twitter.com/StackCodeReview/status/751781302987284480
deleted 1 character in body
Source Link
Ramon
  • 411
  • 3
  • 9

I think this is a decent solution that allows one to simply and independently define commands that useruse argparse, while maintaining and not clashing with any of cmd's functionality.

I think this is a decent solution that allows one to simply and independently define commands that user argparse, while maintaining and not clashing with any of cmd's functionality.

I think this is a decent solution that allows one to simply and independently define commands that use argparse, while maintaining and not clashing with any of cmd's functionality.

Loading
Source Link
Ramon
  • 411
  • 3
  • 9
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /