diff --git a/userdocker/config/default.py b/userdocker/config/default.py index a9db722..81a556e 100644 --- a/userdocker/config/default.py +++ b/userdocker/config/default.py @@ -117,6 +117,15 @@ ], } +# The following arguments sets default values that can be +# overwritten by the user. +# Do not include these args in ARGS_AVAILABLE or ARGS_ALWAYS +ARGS_DEFAULT = { + 'run': { + #'--memory': '50m' + } +} + # Volume mounts: # - VOLUME_MOUNTS_ALWAYS will be mounted whether the user wants it or not diff --git a/userdocker/helpers/parser.py b/userdocker/helpers/parser.py index 29f41d3..78ce27d 100644 --- a/userdocker/helpers/parser.py +++ b/userdocker/helpers/parser.py @@ -5,6 +5,7 @@ from ..config import ARGS_ALWAYS from ..config import ARGS_AVAILABLE +from ..config import ARGS_DEFAULT class _PatchThroughAssignmentAction(argparse._AppendAction): @@ -29,6 +30,10 @@ def init_subcommand_parser(parent_parser, scmd): patch_through_args=[], ) + for arg, val in ARGS_DEFAULT.get(scmd, {}).items(): + parser.add_argument(arg, dest="patch_through_args", action=_PatchThroughAssignmentAction) + parser.set_defaults(patch_through_args=parser.get_default('patch_through_args') + [f'{arg}={val}']) + # patch args through _args_seen = [] for args in ARGS_AVAILABLE.get(scmd, []) + ARGS_ALWAYS.get(scmd, []):