Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: verbose #139

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions devenv/lib/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ class Context(TypedDict):
config_path: str
code_root: str
repo: Repository | None
verbose: bool
2 changes: 2 additions & 0 deletions devenv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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}
Expand Down
9 changes: 9 additions & 0 deletions devenv/sync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import argparse
import importlib.util
import os
from collections.abc import Sequence
Expand All @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i'm trying to use typeguard so i can remove this assert but it's getting a little messy... 3cf7509


Expand All @@ -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

Expand Down
Loading