From: Matthew Fernandez Date: Fri, 6 Jan 2023 06:01:00 +0000 (-0800) Subject: implement '--version' as an alias for '-V' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bddf38bf8e62c55d8a71e0e1dbb76de87805260a;p=graphviz implement '--version' as an alias for '-V' Gitlab: #1618 --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 24a1b762c..795e9e23b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased (7.0.7)] +### Added + +- The command line option `--version` has been added as an alias for `-V`. #1618 + ### Fixed - The Autotools build system no longer errors when attempting libANN discovery diff --git a/lib/common/input.c b/lib/common/input.c index 1778a5eca..d1e7591df 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -269,7 +270,14 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) nfiles = 0; agxbinit(&xb, SMALLBUF, buf); for (i = 1; i < argc; i++) { - if (argv[i] && argv[i][0] == '-') { + if (argv[i] && + (startswith(argv[i], "-V") || strcmp(argv[i], "--version") == 0)) { + fprintf(stderr, "%s - %s version %s (%s)\n", + gvc->common.cmdname, gvc->common.info[0], + gvc->common.info[1], gvc->common.info[2]); + if (GvExitOnUsage) graphviz_exit(0); + return 1; + } else if (argv[i] && argv[i][0] == '-') { rest = &argv[i][2]; switch (c = argv[i][1]) { case 'G': @@ -349,13 +357,6 @@ int dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) case 'P': P_graph = gvplugin_graph(gvc); break; - case 'V': - fprintf(stderr, "%s - %s version %s (%s)\n", - gvc->common.cmdname, gvc->common.info[0], - gvc->common.info[1], gvc->common.info[2]); - if (GvExitOnUsage) graphviz_exit(0); - return (1); - break; case 'l': val = getFlagOpt(argc, argv, &i); if (!val) { diff --git a/tests/test_regression.py b/tests/test_regression.py index c41b9dae5..d0da09a00 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -601,9 +601,9 @@ def test_1594(): assert "line 3:" in stderr, \ "GVPR did not identify correct line of syntax error" -@pytest.mark.parametrize("long,short", (("--help", "-?"), +@pytest.mark.parametrize("long,short", (pytest.param("--help", "-?", + marks=pytest.mark.xfail(strict=True)), ("--version", "-V"))) -@pytest.mark.xfail(strict=True) def test_1618(long: str, short: str): """ Graphviz should understand `--help` and `--version`