---
source: lib/src/sdk/python/mod.rs
expression: client
---
# @generated by usage-cli from test.usage.kdl. Do not edit manually.
from __future__ import annotations
from typing import Optional
from .runtime import CliResult, CliRunner
from .types import RunArgs, RunnerArgs, RunnerFlags

class Runner:
    def __init__(self, bin_path: str = "runner") -> None:
        self._runner = CliRunner(bin_path)
        self.run = Run(self._runner)

    def exec(self, args: RunnerArgs, flags: Optional[RunnerFlags] = None) -> CliResult:
        """[--verbose…] <input> <extra>… <SUBCOMMAND>"""
        cmd_args: list[str] = []
        if args._input is not None: cmd_args.append(str(args._input))
        if args.extra is not None: cmd_args.extend(args.extra)
        # double_dash=automatic: "--" is implied after the first positional arg
        flag_args = self._build_flag_args(flags)
        return self._runner.run(cmd_args + flag_args)

    def _build_flag_args(self, flags: Optional[RunnerFlags]) -> list[str]:
        result: list[str] = []
        if flags is None: return result
        if flags.verbose is not None:
            for v in flags.verbose:
                if v: result.append("--verbose")
        return result

class Run:
    """Run a task"""
    def __init__(self, runner: CliRunner) -> None:
        self._runner = runner

    def exec(self, args: RunArgs) -> CliResult:
        """run <task>
        Basic run: runner run hello
        """
        cmd_args: list[str] = ["run"]
        if args.task is not None: cmd_args.append(str(args.task))
        # double_dash=automatic: "--" is implied after the first positional arg
        return self._runner.run(cmd_args)
