Skip to content

Commit a4ba4bb

Browse files
committed
feat: accept --help, finally
1 parent 03058f8 commit a4ba4bb

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Unreleased
3131
making checksums less visually distracting. The old hex format will still be
3232
accepted, but will be updated to the new format automatically when writing.
3333

34+
- Added ``--help`` option as an alias for ``-h``.
35+
3436
- Dropped support for Python 3.7 and 3.8, and added 3.13.
3537

3638

cogapp/cogapp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
--verbosity=VERBOSITY
6161
Control the amount of output. 2 (the default) lists all files,
6262
1 lists only changed files, 0 lists no files.
63-
-h Print this help.
63+
-h, --help Print this help.
6464
"""
6565

6666

@@ -775,7 +775,7 @@ def callable_main(self, argv):
775775
argv = argv[1:]
776776

777777
# Provide help if asked for anywhere in the command line.
778-
if "-?" in argv or "-h" in argv:
778+
if "-?" in argv or "-h" in argv or "--help" in argv:
779779
self.prerr(usage, end="")
780780
return
781781

@@ -804,7 +804,7 @@ def main(self, argv):
804804
return 0
805805
except CogUsageError as err:
806806
self.prerr(err)
807-
self.prerr("(for help use -h)")
807+
self.prerr("(for help use --help)")
808808
return 2
809809
except CogGeneratedError as err:
810810
self.prerr(f"Error: {err}")

cogapp/test_cogapp.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,12 @@ def produces_help(self, args):
843843
self.assertEqual(usage, self.output.getvalue())
844844

845845
def test_dash_h(self):
846-
# -h or -? anywhere on the command line should just print help.
846+
# -h, --help, or -? anywhere on the command line should just print help.
847847
self.produces_help("-h")
848+
self.produces_help("--help")
848849
self.produces_help("-?")
849850
self.produces_help("fooey.txt -h")
851+
self.produces_help("fooey.txt --help")
850852
self.produces_help("-o -r @fooey.txt -? @booey.txt")
851853

852854
def test_dash_o_and_dash_r(self):
@@ -931,7 +933,7 @@ def test_main_function(self):
931933
ret = main()
932934
self.assertEqual(ret, 2)
933935
stderr = sys.stderr.getvalue()
934-
self.assertEqual(stderr, "option -Z not recognized\n(for help use -h)\n")
936+
self.assertEqual(stderr, "option -Z not recognized\n(for help use --help)\n")
935937

936938
files = {
937939
"test.cog": """\

docs/running.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ Cog is a command-line utility which takes arguments in standard form.
6464
--verbosity=VERBOSITY
6565
Control the amount of output. 2 (the default) lists all files,
6666
1 lists only changed files, 0 lists no files.
67-
-h Print this help.
67+
-h, --help Print this help.
6868
69-
.. {{{end}}} (checksum: d9737a8e9fc9c2fc78a5200f2fa8440f)
69+
.. {{{end}}} (sum: aE5SIko6oj)
7070
7171
In addition to running cog as a command on the command line, you can also
7272
invoke it as a module with the Python interpreter:

0 commit comments

Comments
 (0)