-
Notifications
You must be signed in to change notification settings - Fork 0
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 #45 from elcaminoreal/missing-bits
fix example stuff
- Loading branch information
Showing
4 changed files
with
29 additions
and
26 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
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) |