MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / execute_args

Method execute_args

keepercommander/commands/base.py:851–891  ·  view source on GitHub ↗
(self, params, args, **kwargs)

Source from the content-addressed store, hash-verified

849 self._aliases[alias] = verb
850
851 def execute_args(self, params, args, **kwargs): # type: (KeeperParams, str, dict) -> any
852 if args.startswith('-- '):
853 args = args[3:].strip()
854 self.validate(params)
855 pos = args.find(' ')
856 if pos > 0:
857 verb = args[:pos].strip()
858 args = args[pos + 1:].strip()
859 else:
860 verb = args.strip()
861 args = ''
862
863 print_help = False
864 if not verb:
865 verb = self.default_verb
866 print_help = True
867 if verb:
868 verb = verb.lower()
869
870 if verb in self._aliases:
871 verb = self._aliases[verb]
872
873 command = self._commands.get(verb)
874 if not command:
875 print_help = True
876 if verb not in ['--help', '-h', 'help', '']:
877 logging.warning('Invalid command: %s', verb)
878
879 if print_help:
880 self.print_help(**kwargs)
881
882 if command:
883 kwargs['action'] = verb
884 if command.is_authorised() and not params.session_token:
885 from .utils import LoginCommand
886 login_cmd = LoginCommand()
887 login_cmd.execute(params)
888 if not params.session_token:
889 return
890
891 return command.execute_args(params, args, **kwargs)
892
893 def print_help(self, **kwargs):
894 print(f'{kwargs.get("command")} command [--options]')

Callers

nothing calls this directly

Calls 8

validateMethod · 0.95
print_helpMethod · 0.95
executeMethod · 0.95
LoginCommandClass · 0.85
warningMethod · 0.80
getMethod · 0.45
is_authorisedMethod · 0.45
execute_argsMethod · 0.45

Tested by

no test coverage detected