Skip to content

Commit

Permalink
Convert projects-run to typer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 15, 2024
1 parent e96a9d4 commit f07f22f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
49 changes: 23 additions & 26 deletions jaraco/develop/projects-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,37 @@
Routine to run a command across all projects.
"""

import argparse
import functools
import subprocess
from typing import List, cast

import autocommand
import typer
from jaraco.ui.main import main
from typing_extensions import Annotated

from . import filters, git

parser = argparse.ArgumentParser()
parser.add_argument(
'--keyword',
'-k',
dest='selectors',
type=filters.Keyword,
default=filters.Selectors(),
action='append',
)
parser.add_argument(
'--tag',
'-t',
dest='selectors',
type=filters.Tag,
default=filters.Selectors(),
action='append',
)
parser.add_argument('args', nargs='*')


@autocommand.autocommand(__name__, parser=parser)
def main(
selectors: filters.Selectors,
args=None,
@functools.partial(
main,
app=typer.Typer(
context_settings=dict(allow_extra_args=True, ignore_unknown_options=True)
),
)
def run(
tag: Annotated[
List[filters.Tag], typer.Option('--tag', '-t', parser=filters.Tag)
] = [],
keyword: Annotated[
List[filters.Keyword],
typer.Option('--keyword', '-k', parser=filters.Keyword),
] = [],
args: typer.Context = typer.Option(None),
):
cmd = cast(List[str], args.args)
selectors = filters.Selectors(tag + keyword)
for project in filter(selectors, git.projects()):
print(project, flush=True)
with git.temp_checkout(project, quiet=True):
subprocess.Popen(args).wait()
subprocess.Popen(cmd).wait()
print(flush=True)
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies = [
"jaraco.ui >= 2.4",
"jaraco.context",
"keyring",
"autocommand",
"requests-toolbelt",
"PyNaCl",
"packaging",
Expand Down

0 comments on commit f07f22f

Please sign in to comment.