diff --git a/src/devcenter/azext_devcenter/action.py b/src/devcenter/azext_devcenter/action.py index 9b3d0a8a78c..a0efa31155a 100644 --- a/src/devcenter/azext_devcenter/action.py +++ b/src/devcenter/azext_devcenter/action.py @@ -9,7 +9,9 @@ # -------------------------------------------------------------------------- # pylint: disable=wildcard-import # pylint: disable=unused-wildcard-import - +import argparse +from collections import defaultdict +from knack.util import CLIError from .generated.action import * # noqa: F403 try: from .manual.action import * # noqa: F403 @@ -18,3 +20,44 @@ pass else: raise e + +class AddGitHub(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + if option_string == '--ado-git': + namespace.ado_git = action + else: + namespace.git_hub = action + + def get_action(self, values, option_string): + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + + if kl == 'uri': + d['uri'] = v[0] + + elif kl == 'branch': + d['branch'] = v[0] + + elif kl == 'secret-identifier': + d['secret_identifier'] = v[0] + + elif kl == 'path': + d['path'] = v[0] + + else: + raise CLIError( + 'Unsupported Key {} is provided for parameter git-hub. All possible keys are: uri, branch,' + ' secret-identifier, path'.format(k) + ) + + return d diff --git a/src/devcenter/src/devcenter/devcenter-0.1.0-py3-none-any.whl b/src/devcenter/src/devcenter/devcenter-0.1.0-py3-none-any.whl index 381e4b34b40..c0d896e3cfd 100644 Binary files a/src/devcenter/src/devcenter/devcenter-0.1.0-py3-none-any.whl and b/src/devcenter/src/devcenter/devcenter-0.1.0-py3-none-any.whl differ diff --git a/src/devcenter/src/devcenter/devcenter-0.1.0.zip b/src/devcenter/src/devcenter/devcenter-0.1.0.zip index 5dc99303b32..9de47af5095 100644 Binary files a/src/devcenter/src/devcenter/devcenter-0.1.0.zip and b/src/devcenter/src/devcenter/devcenter-0.1.0.zip differ