Skip to content
Snippets Groups Projects
Commit 8860bb05 authored by sveseli's avatar sveseli
Browse files

allow arbitrary args to be converted into dicts

parent 43270239
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,8 @@ from dm.common.constants import dmStatus ...@@ -21,6 +21,8 @@ from dm.common.constants import dmStatus
class DmCli(object): class DmCli(object):
""" Base dm command line interface class. """ """ Base dm command line interface class. """
DEFAULT_SESSION_CACHE_FILE = OsUtility.getUserHomeDir() + '/.dm/.session.cache' DEFAULT_SESSION_CACHE_FILE = OsUtility.getUserHomeDir() + '/.dm/.session.cache'
ANY_NUMBER_OF_POSITIONAL_ARGS = 10000000
def __init__(self, validArgCount=0): def __init__(self, validArgCount=0):
self.logger = LoggingManager.getInstance().getLogger(self.__class__.__name__) self.logger = LoggingManager.getInstance().getLogger(self.__class__.__name__)
# Do not log into a file for CLIs # Do not log into a file for CLIs
...@@ -178,6 +180,19 @@ class DmCli(object): ...@@ -178,6 +180,19 @@ class DmCli(object):
""" Returns the command line argument list. """ """ Returns the command line argument list. """
return self.args return self.args
def splitArgsIntoDict(self, keyValueDelimiter=':'):
""" Returns the command line argument list as dictionary of key/value
pairs. Each argument is split using specified delimiter. """
argDict = {}
for a in self.args:
sList = a.split(keyValueDelimiter)
key = sList[0]
value = ''
if len(sList) > 1:
value = keyValueDelimiter.join(sList[1:])
argDict[key] = value
return argDict
def getArg(self, i): def getArg(self, i):
""" Returns the i-th command line argument. """ """ Returns the i-th command line argument. """
return self.args[i] return self.args[i]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment