Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion src/devcenter/azext_devcenter/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Binary file modified src/devcenter/src/devcenter/devcenter-0.1.0-py3-none-any.whl
Binary file not shown.
Binary file modified src/devcenter/src/devcenter/devcenter-0.1.0.zip
Binary file not shown.