From: Matthew Fernandez Date: Fri, 6 Jan 2023 06:01:00 +0000 (-0800) Subject: implement '--help' as an alias for '-?' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f08625052c5f28a642cdba174af2d59786746f5;p=graphviz implement '--help' as an alias for '-?' Gitlab: closes #1618 Reported-by: Basile Starynkevitch --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 795e9e23b..5e7a67ad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- The command line option `--help` has been added as an alias for `-?`. #1618 - The command line option `--version` has been added as an alias for `-V`. #1618 ### Fixed diff --git a/lib/common/input.c b/lib/common/input.c index d1e7591df..f40bc5103 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -277,6 +277,9 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) gvc->common.info[1], gvc->common.info[2]); if (GvExitOnUsage) graphviz_exit(0); return 1; + } else if (argv[i] && + (startswith(argv[i], "-?") || strcmp(argv[i], "--help") == 0)) { + return dotneato_usage(0); } else if (argv[i] && argv[i][0] == '-') { rest = &argv[i][2]; switch (c = argv[i][1]) { @@ -408,9 +411,6 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) case 'y': Y_invert = TRUE; break; - case '?': - return (dotneato_usage(0)); - break; default: agerr(AGERR, "%s: option -%c unrecognized\n\n", gvc->common.cmdname, c); diff --git a/tests/test_regression.py b/tests/test_regression.py index d0da09a00..88f258349 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -601,8 +601,7 @@ def test_1594(): assert "line 3:" in stderr, \ "GVPR did not identify correct line of syntax error" -@pytest.mark.parametrize("long,short", (pytest.param("--help", "-?", - marks=pytest.mark.xfail(strict=True)), +@pytest.mark.parametrize("long,short", (("--help", "-?"), ("--version", "-V"))) def test_1618(long: str, short: str): """