Skip to content

Commit 06be224

Browse files
Fixed --help not working for aliases
1 parent 8fe0e70 commit 06be224

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

linodecli/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
skip_config = (
4949
any(
5050
c in argv
51-
for c in ["--skip-config", "--help", "--version", "completion"]
51+
for c in ["--skip-config", "--version", "completion"]
5252
)
5353
or TEST_MODE
5454
)
@@ -260,7 +260,6 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
260260
plugin_args.remove(parsed.command) # don't include the plugin name
261261
plugins.invoke(parsed.command, plugin_args, context)
262262
sys.exit(ExitCodes.SUCCESS)
263-
264263
# unknown commands
265264
if (
266265
parsed.command not in cli.ops
@@ -275,14 +274,19 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
275274
if (
276275
parsed.command is not None
277276
and parsed.action is None
278-
and parsed.command in cli.ops
279277
):
280-
print_help_command_actions(cli.ops, parsed.command)
281-
sys.exit(ExitCodes.SUCCESS)
278+
if parsed.command in cli.ops:
279+
print_help_command_actions(cli.ops, parsed.command)
280+
sys.exit(ExitCodes.SUCCESS)
281+
if parsed.command in cli.config.get_custom_aliases().keys():
282+
print_help_command_actions(cli.ops, cli.config.get_custom_aliases()[parsed.command])
282283

283284
if parsed.command is not None and parsed.action is not None:
284285
if parsed.help:
285-
print_help_action(cli, parsed.command, parsed.action)
286+
if parsed.command in cli.config.get_custom_aliases().keys():
287+
print_help_action(cli, cli.config.get_custom_aliases()[parsed.command], parsed.action)
288+
else:
289+
print_help_action(cli, parsed.command, parsed.action)
286290
sys.exit(ExitCodes.SUCCESS)
287291

288292
cli.handle_command(parsed.command, parsed.action, args)

linodecli/cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ def find_operation(self, command, action):
240240
if command not in self.ops:
241241
# Check that the passed command is not an alias before raising an error
242242
if command in self.config.get_custom_aliases().keys():
243-
print(command)
244243
command = self.config.get_custom_aliases()[command]
245-
print(command)
246244
else:
247245
raise ValueError(f"Command not found: {command}")
248246

0 commit comments

Comments
 (0)