Skip to content

Commit ae124b4

Browse files
committed
feat: add new function for invalid input and remove -V flag
1 parent 2408c82 commit ae124b4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/diffpy/cmi/app.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
def usage():
8-
"""Print short help message."""
8+
"""Print full help message."""
99
print(
1010
"""\
1111
@@ -24,29 +24,37 @@ def usage():
2424
diffpy-cmi [--version] [--help]
2525
2626
Options:
27-
-V, --version Show version and exit
27+
--version Show version and exit
2828
-h, --help Show this message and exit
2929
"""
3030
)
3131

3232

33+
def short_usage():
34+
"""Print brief usage message for invalid input."""
35+
print(
36+
"Usage: diffpy-cmi [--version] [--help]\nUse --help to see more.",
37+
file=sys.stderr,
38+
)
39+
40+
3341
def print_version():
3442
print(f"diffpy-cmi {__version__}")
3543

3644

3745
def main():
3846
try:
39-
opts, args = getopt.gnu_getopt(sys.argv[1:], "hV", ["help", "version"])
47+
opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ["help", "version"])
4048
except getopt.GetoptError as err:
4149
print(f"Error: {err}", file=sys.stderr)
42-
usage()
50+
short_usage()
4351
sys.exit(1)
4452

4553
for opt, _ in opts:
4654
if opt in ("-h", "--help"):
4755
usage()
4856
return
49-
elif opt in ("-V", "--version"):
57+
elif opt == "--version":
5058
print_version()
5159
return
5260

0 commit comments

Comments
 (0)