From 558ca099d257d662e179f6d28e0be14c98aafbd7 Mon Sep 17 00:00:00 2001 From: umarcor Date: Sun, 1 Aug 2021 20:48:13 +0200 Subject: [PATCH] WIP handle '--' in pydoit --- dodo.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/dodo.py b/dodo.py index 938940a47..8e899be21 100644 --- a/dodo.py +++ b/dodo.py @@ -1,16 +1,21 @@ +#!/usr/bin/env python3 + # doit -from sys import executable +from sys import executable, argv as sys_argv, exit as sys_exit from os import environ from pathlib import Path from doit.action import CmdAction +from doit.cmd_base import ModuleTaskLoader +from doit.doit_cmd import DoitMain from tasks.examples import Example, GenerateExamplesJobMatrix, PRJ BOARDS = PRJ.Boards DOIT_CONFIG = {"verbosity": 2, "action_string_formatting": "both"} +EXTRA_ARGS = [] ROOT = Path(__file__).parent @@ -203,3 +208,29 @@ def task_DeployToGitHubPages(): "doc": "Create a clean branch in subdir 'public' and push to branch 'gh-pages'", "pos_arg": "posargs", } + + +def task_echo(): + return { + 'actions': ['echo hi {args}'], + 'verbosity': 2, + "params": [ + { + "name": "args", + "short": "a", + "long": "args", + "type": list, + "default": EXTRA_ARGS, + "help": "Arguments to pass to the VUnit script", + } + ], + } + + +if __name__ == '__main__': + argv = sys_argv[1:] + if '--' in argv: + idx = argv.index('--') + EXTRA_ARGS = argv[idx+1:] + argv = argv[0:idx] + sys_exit(DoitMain(ModuleTaskLoader(globals())).run(argv))