-
Notifications
You must be signed in to change notification settings - Fork 8
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 #223 from xen0n/cmd-plugin
Support plugin-provided Ruyi subcommands
- Loading branch information
Showing
13 changed files
with
245 additions
and
35 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
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,35 @@ | ||
import argparse | ||
|
||
from ..cli.cmd import AdminCommand | ||
from ..config import GlobalConfig | ||
from ..ruyipkg.repo import MetadataRepo | ||
|
||
|
||
class AdminRunPluginCommand( | ||
AdminCommand, | ||
cmd="run-plugin-cmd", | ||
help="Run a plugin-defined command", | ||
): | ||
@classmethod | ||
def configure_args(cls, p: argparse.ArgumentParser) -> None: | ||
p.add_argument( | ||
"cmd_name", | ||
type=str, | ||
metavar="COMMAND-NAME", | ||
help="Command name", | ||
) | ||
p.add_argument( | ||
"cmd_args", | ||
type=str, | ||
nargs="*", | ||
metavar="COMMAND-ARG", | ||
help="Arguments to pass to the plugin command", | ||
) | ||
|
||
@classmethod | ||
def main(cls, cfg: GlobalConfig, args: argparse.Namespace) -> int: | ||
cmd_name = args.cmd_name | ||
cmd_args = args.cmd_args | ||
|
||
mr = MetadataRepo(cfg) | ||
return mr.run_plugin_cmd(cmd_name, cmd_args) |
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
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,17 @@ | ||
RUYI = ruyi_plugin_rev(1) | ||
|
||
|
||
def fn1(mgr): | ||
def _with_inner(obj): | ||
return obj * 2 | ||
return RUYI.with_(mgr, _with_inner) | ||
|
||
|
||
def fn2(mgr): | ||
def _with_inner(obj): | ||
return mgr.NoNeXiStEnT | ||
return RUYI.with_(mgr, _with_inner) | ||
|
||
|
||
def fn3(mgr, py_fn): | ||
return RUYI.with_(mgr, py_fn) |
Empty file.
Oops, something went wrong.