diff --git a/devenv/lib/context.py b/devenv/lib/context.py index 9377ca46..33a9083d 100644 --- a/devenv/lib/context.py +++ b/devenv/lib/context.py @@ -9,3 +9,4 @@ class Context(TypedDict): config_path: str code_root: str repo: Repository | None + verbose: bool diff --git a/devenv/main.py b/devenv/main.py index 0c9077f6..a77a4bc2 100644 --- a/devenv/main.py +++ b/devenv/main.py @@ -52,6 +52,7 @@ def devenv(argv: Sequence[str], config_path: str) -> ExitCode: parser = argparse.ArgumentParser() parser.add_argument("--version", action="version", version=version) + parser.add_argument("-v", "--verbose", action="store_true") subparser = parser.add_subparsers( title=argparse.SUPPRESS, metavar="command", @@ -74,6 +75,7 @@ def devenv(argv: Sequence[str], config_path: str) -> ExitCode: "config_path": config_path, "code_root": code_root, "repo": Repository(current_root) if current_root else None, + "verbose": args.verbose, } command_actions = {info.command: info.action for info in modinfo_list} diff --git a/devenv/sync.py b/devenv/sync.py index e03ac639..a0205f61 100644 --- a/devenv/sync.py +++ b/devenv/sync.py @@ -1,5 +1,6 @@ from __future__ import annotations +import argparse import importlib.util import os from collections.abc import Sequence @@ -11,6 +12,13 @@ @require_repo def main(context: Context, argv: Sequence[str] | None = None) -> int: + parser = argparse.ArgumentParser() + parser.add_argument("-v", "--verbose", action="store_true") + args = parser.parse_args(argv) + + # also support devenv sync -v in addition to devenv -v sync + verbose = context["verbose"] or args.verbose + repo = context["repo"] assert repo is not None @@ -29,6 +37,7 @@ def main(context: Context, argv: Sequence[str] | None = None) -> int: "reporoot": repo.path, "repo": repo.name, "coderoot": context.get("code_root"), + "verbose": verbose, } return module.main(context_compat) # type: ignore