コード例 #1
0
ファイル: utils.py プロジェクト: ZettaAI/cloud-bot-workers
def _get_nested_command(grp: Group, names: Iterable[str]) -> Union[Group, Command]:
    """Recursively find nested command and get it's help."""
    if len(names) == 1:
        return grp.get_command(Context(grp, info_name=grp.name), names[0])
    else:
        child_grp = grp.get_command(Context(grp, info_name=grp.name), names[0])
        return _get_nested_command(child_grp, names[1:])
コード例 #2
0
 def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]:
     rv = Group.get_command(self, ctx, cmd_name)
     if rv:
         return rv
     dashed = cmd_name.replace("_", "-")
     for cmd in self.list_commands(ctx):
         if cmd == dashed:
             return Group.get_command(self, ctx, cmd)
     return None
コード例 #3
0
ファイル: classes.py プロジェクト: oretakarl/spotify-cli
 def get_command(self, ctx, cmd_name):
     rv = Group.get_command(self, ctx, cmd_name)
     if rv is not None:
         return rv
     matches = [
         x for x in self.list_commands(ctx) if x.startswith(cmd_name)
     ]
     if not matches:
         return None
     elif len(matches) == 1:
         return Group.get_command(self, ctx, matches[0])
     ctx.fail('Too many matches: %s' % ', '.join(sorted(matches)))