Fix TargetArgument implementation to stay optional

This commit is contained in:
jpic 2020-08-08 15:54:02 +02:00
parent 12edb5168f
commit ce931a2cc6

View File

@ -32,9 +32,11 @@ class TargetArgument(cli2.Argument):
def cast(self, value): def cast(self, value):
from shlax.targets.ssh import Ssh from shlax.targets.ssh import Ssh
if '@' in value: user, host = value.split('@')
user, host = value.split('@') return Ssh(host=host, user=user)
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): class Command(cli2.Command):