diff --git a/linodecli/cli.py b/linodecli/cli.py index 419b5e06e..230b9275d 100644 --- a/linodecli/cli.py +++ b/linodecli/cli.py @@ -25,7 +25,13 @@ METHODS = ("get", "post", "put", "delete") logger = getLogger(__name__) +args = sys.argv[1:] +if len(args) > 0 and args[-1] == "help": + sys.argv = [sys.argv[0]] + args[:-1] + ["--help"] + +elif len(args) > 0 and args[0] == "help": + sys.argv = [sys.argv[0]] + args[1:] + ["--help"] class CLI: # pylint: disable=too-many-instance-attributes """ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..b444b8e10 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "linode-cli", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/tests/test_help_alias.py b/tests/test_help_alias.py new file mode 100644 index 000000000..8254b8735 --- /dev/null +++ b/tests/test_help_alias.py @@ -0,0 +1,18 @@ +import subprocess +import os +def test_help_alias(): + env = os.environ.copy() + env["LINODE_CLI_CONFIG"] = "/dev/null" + env["HOME"] = "/tmp" + + result = subprocess.run( + ["python3", "-m", "linodecli", "instance", "help"], + capture_output=True, + text=True, + timeout=5, + env=env, + input="\n" + ) + + assert result.returncode == 0 + assert "usage" in result.stdout.lower() \ No newline at end of file