Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from elcaminoreal/use-cd-run
use commander data's run abstractions
- Loading branch information
Showing
11 changed files
with
97 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.11 | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --extra=mypy --output-file=requirements-mypy.txt pyproject.toml | ||
# pip-compile --output-file=- - | ||
# | ||
attrs==23.2.0 | ||
# via gather (pyproject.toml) | ||
# via -r - | ||
commander-data==2024.1.17.82975 | ||
# via -r - | ||
incremental==22.10.0 | ||
# via gather (pyproject.toml) | ||
# via -r - | ||
mypy==1.8.0 | ||
# via gather (pyproject.toml) | ||
# via -r - | ||
mypy-extensions==1.0.0 | ||
# via mypy | ||
toolz==0.12.0 | ||
# via gather (pyproject.toml) | ||
# via -r - | ||
typing-extensions==4.9.0 | ||
# via mypy | ||
venusian==3.1.0 | ||
# via gather (pyproject.toml) | ||
# via -r - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --output-file=- - | ||
# | ||
attrs==23.2.0 | ||
# via -r - | ||
commander-data==2024.1.17.82975 | ||
# via -r - | ||
incremental==22.10.0 | ||
# via -r - | ||
toolz==0.12.0 | ||
# via -r - | ||
venusian==3.1.0 | ||
# via -r - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" | ||
Example commands and plugins | ||
""" | ||
|
||
from gather import entry | ||
|
||
ENTRY_DATA = entry.EntryData.create(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
"""Run the example commands""" | ||
from gather import entry | ||
from . import ENTRY_DATA | ||
|
||
if __name__ != "__main__": | ||
raise ImportError("only run") | ||
|
||
from . import main | ||
from gather.commands import run | ||
|
||
run(parser=main.get_parser()) | ||
entry.dunder_main( | ||
globals_dct=globals(), | ||
command_data=ENTRY_DATA, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
"""Example commands""" | ||
import sys | ||
import gather | ||
from gather import commands | ||
from gather.commands import add_argument | ||
|
||
_COMMANDS_COLLECTOR = gather.Collector() | ||
REGISTER = commands.make_command_register(_COMMANDS_COLLECTOR) | ||
from commander_data.common import LOCAL_PYTHON as PYTHON | ||
|
||
from gather.commands import add_argument | ||
|
||
def get_parser(): | ||
"""Get parser dispatching to example commands""" | ||
return commands.set_parser(collected=_COMMANDS_COLLECTOR.collect()) | ||
from . import ENTRY_DATA | ||
|
||
|
||
@REGISTER( | ||
@ENTRY_DATA.register( | ||
add_argument("--value"), | ||
name="do-something", | ||
) | ||
def _do_something(*, args, env, run): | ||
def _do_something(args): | ||
print(args.value) | ||
print(env["SHELL"]) | ||
run([sys.executable, "-c", "print(1+1)"], check=True) | ||
print(args.env["SHELL"]) | ||
args.safe_run(PYTHON(c="print(1+1)"), capture_output=False) | ||
|
||
|
||
@REGISTER( | ||
@ENTRY_DATA.register( | ||
add_argument("--no-dry-run", action="store_true"), | ||
name="do-something-else", | ||
) | ||
def _do_something_else(*, args, env, run): | ||
def _do_something_else(args): | ||
print(args.no_dry_run) | ||
print(env["SHELL"]) | ||
run([sys.executable, "-c", "print(1+1)"], check=True) | ||
print(args.env["SHELL"]) | ||
args.safe_run(PYTHON(c="print(1+1)"), capture_output=False) |