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,10 +32,12 @@ 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):
def setargs(self): def setargs(self):