mirror of
https://github.com/daylinmorgan/swydd.git
synced 2024-11-23 15:20:43 -06:00
feat: keep positional args in context
This commit is contained in:
parent
5115f72db6
commit
3bf6c4e722
1 changed files with 8 additions and 3 deletions
|
@ -101,6 +101,7 @@ class Context:
|
||||||
self._flag_defs: List[Tuple[Tuple[str, ...], Any]] = []
|
self._flag_defs: List[Tuple[Tuple[str, ...], Any]] = []
|
||||||
self.show_targets = True
|
self.show_targets = True
|
||||||
self._graph = Graph()
|
self._graph = Graph()
|
||||||
|
self.rest = [] # remaining positional args
|
||||||
|
|
||||||
# global flags
|
# global flags
|
||||||
self.dry = False
|
self.dry = False
|
||||||
|
@ -568,8 +569,7 @@ def option(
|
||||||
|
|
||||||
|
|
||||||
def manage(version: bool = False) -> None:
|
def manage(version: bool = False) -> None:
|
||||||
"""manage self"""
|
"""internal cli"""
|
||||||
print("self management stuff")
|
|
||||||
if version:
|
if version:
|
||||||
print("current version", __version__)
|
print("current version", __version__)
|
||||||
|
|
||||||
|
@ -712,8 +712,13 @@ def cli() -> None:
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
parser.print_help(sys.stderr)
|
parser.print_help(sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
elif "--" in sys.argv:
|
||||||
|
i = sys.argv.index("--")
|
||||||
|
args = vars(parser.parse_args(sys.argv[1:i]))
|
||||||
|
ctx.rest = sys.argv[i + 1 :]
|
||||||
|
else:
|
||||||
args = vars(parser.parse_args())
|
args = vars(parser.parse_args())
|
||||||
|
|
||||||
_ = args.pop("pos-arg", None)
|
_ = args.pop("pos-arg", None)
|
||||||
ctx.verbose = args.pop("verbose", False)
|
ctx.verbose = args.pop("verbose", False)
|
||||||
ctx.dry = args.pop("dry_run", False)
|
ctx.dry = args.pop("dry_run", False)
|
||||||
|
|
Loading…
Reference in a new issue