Esempio n. 1
0
    def _help(self, args: Args) -> AnyErr:
        cmd = args.get_positional()

        if not cmd:
            ok = command_man("usage")
        else:
            ok = False

            commands = self._commands_for(cmd, resolve_alias=False)

            target = self._resolve_alias(cmd, recursive=False)
            if target:
                print(f"alias {cmd}={target}")
                ok = True
            else:
                log.w(f"Neither a command nor an alias: '{cmd}'")

            if commands:
                if len(commands) == 1:
                    command = commands[0]
                    log.d(f"{cmd} resolve into known {command}")
                    ok = command_man(command)
                elif len(commands) > 1:
                    print("Available commands: ")
                    for comm in isorted(commands):
                        print(red(cmd) + comm[len(cmd):])
                    ok = True

        if not ok:
            print(f"Can't provide help for '{cmd}'")

        return ClientErrors.SUCCESS
Esempio n. 2
0
    def _trace(args: Args) -> AnyErr:
        """ trace - changes the tracing level """

        # Increase tracing level (or disable if is already max)
        level = args.get_positional(
            default=(get_setting(Settings.TRACING) + 1) % (TRACING_MAX + 1))

        log.i(f">> TRACING ({level})")
        set_setting(Settings.TRACING, level)

        return ClientErrors.SUCCESS
Esempio n. 3
0
    def _verbose(args: Args) -> AnyErr:
        """ verbose - changes the verbosity level """

        # Increase verbosity (or disable if is already max)
        verbosity = args.get_positional(
            default=(get_setting(Settings.VERBOSITY) + 1) %
            (VERBOSITY_MAX + 1))

        log.i(f">> VERBOSE ({verbosity})")
        set_setting(Settings.VERBOSITY, verbosity)

        return ClientErrors.SUCCESS