From ce931a2cc6401ac8dc1e993ddaa9e8500366ff83 Mon Sep 17 00:00:00 2001 From: jpic Date: Sat, 8 Aug 2020 15:54:02 +0200 Subject: [PATCH] Fix TargetArgument implementation to stay optional --- shlax/cli.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shlax/cli.py b/shlax/cli.py index 7757975..390c784 100644 --- a/shlax/cli.py +++ b/shlax/cli.py @@ -32,9 +32,11 @@ class TargetArgument(cli2.Argument): def cast(self, value): from shlax.targets.ssh import Ssh - if '@' in value: - user, host = value.split('@') - return Ssh(host=host, user=user) + user, host = value.split('@') + return Ssh(host=host, user=user) + + def match(self, arg): + return arg if isinstance(arg, str) and '@' in arg else None class Command(cli2.Command):