plugins: Invoke setup_parser_common_args explicitly from setup_parser
This allows to define plugins which do not need have any of common args. Move setup_parser_common_args into libkas for this as it now becomes a library function. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
6dd27e7c62
commit
4c975a04f9
15
kas/kas.py
15
kas/kas.py
@ -97,20 +97,6 @@ def _atexit_handler():
|
||||
loop.close()
|
||||
|
||||
|
||||
def setup_parser_common_args(parser):
|
||||
parser.add_argument('config',
|
||||
help='Config file')
|
||||
parser.add_argument('--skip',
|
||||
help='Skip build steps',
|
||||
default=[])
|
||||
parser.add_argument('--force-checkout', action='store_true',
|
||||
help='Always checkout the desired refspec of each '
|
||||
'repository, discarding any local changes')
|
||||
parser.add_argument('--update', action='store_true',
|
||||
help='Pull new upstream changes to the desired '
|
||||
'refspec even if it is already checked out locally')
|
||||
|
||||
|
||||
def kas_get_argparser():
|
||||
"""
|
||||
Creates an argparser for kas with all plugins.
|
||||
@ -137,7 +123,6 @@ def kas_get_argparser():
|
||||
|
||||
for plugin in plugins.all():
|
||||
plugin_parser = subparser.add_parser(plugin.name, help=plugin.helpmsg)
|
||||
setup_parser_common_args(plugin_parser)
|
||||
plugin.setup_parser(plugin_parser)
|
||||
|
||||
return parser
|
||||
|
@ -359,3 +359,17 @@ def ssh_no_host_key_check():
|
||||
os.mkdir(home + '/.ssh')
|
||||
with open(home + '/.ssh/config', 'w') as fds:
|
||||
fds.write('Host *\n\tStrictHostKeyChecking no\n\n')
|
||||
|
||||
|
||||
def setup_parser_common_args(parser):
|
||||
parser.add_argument('config',
|
||||
help='Config file')
|
||||
parser.add_argument('--skip',
|
||||
help='Skip build steps',
|
||||
default=[])
|
||||
parser.add_argument('--force-checkout', action='store_true',
|
||||
help='Always checkout the desired refspec of each '
|
||||
'repository, discarding any local changes')
|
||||
parser.add_argument('--update', action='store_true',
|
||||
help='Pull new upstream changes to the desired '
|
||||
'refspec even if it is already checked out locally')
|
||||
|
@ -39,6 +39,7 @@ from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libkas import find_program, run_cmd
|
||||
from kas.libcmds import Macro, Command
|
||||
from kas.libkas import setup_parser_common_args
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
||||
@ -61,6 +62,7 @@ class Build:
|
||||
Setup the argument parser for the build plugin
|
||||
"""
|
||||
|
||||
setup_parser_common_args(parser)
|
||||
parser.add_argument('extra_bitbake_args',
|
||||
nargs='*',
|
||||
help='Extra arguments to pass to bitbake '
|
||||
|
@ -36,6 +36,7 @@
|
||||
from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libcmds import Macro
|
||||
from kas.libkas import setup_parser_common_args
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
||||
@ -50,7 +51,7 @@ class Checkout:
|
||||
|
||||
@classmethod
|
||||
def setup_parser(cls, parser):
|
||||
pass
|
||||
setup_parser_common_args(parser)
|
||||
|
||||
def run(self, args):
|
||||
ctx = create_global_context(args)
|
||||
|
@ -59,6 +59,7 @@ import sys
|
||||
from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libcmds import Macro, Command
|
||||
from kas.libkas import setup_parser_common_args
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
||||
@ -72,6 +73,7 @@ class ForAllRepos:
|
||||
|
||||
@classmethod
|
||||
def setup_parser(cls, parser):
|
||||
setup_parser_common_args(parser)
|
||||
parser.add_argument('command',
|
||||
help='Command to be executed as a string.')
|
||||
|
||||
|
@ -43,6 +43,7 @@ import sys
|
||||
from kas.context import create_global_context
|
||||
from kas.config import Config
|
||||
from kas.libcmds import Macro, Command
|
||||
from kas.libkas import setup_parser_common_args
|
||||
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) Siemens AG, 2017-2018'
|
||||
@ -62,6 +63,7 @@ class Shell:
|
||||
Setup the argument parser for the shell plugin
|
||||
"""
|
||||
|
||||
setup_parser_common_args(parser)
|
||||
parser.add_argument('-k', '--keep-config-unchanged',
|
||||
help='Skip steps that change the configuration',
|
||||
action='store_true')
|
||||
|
Loading…
Reference in New Issue
Block a user