add valid_mandatory to parse_args
This commit is contained in:
parent
6de205b260
commit
e61e064c41
1 changed files with 12 additions and 8 deletions
|
@ -219,7 +219,10 @@ class TiramisuCmdlineParser(ArgumentParser):
|
||||||
group.add_argument(*args, **kwargs)
|
group.add_argument(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def parse_args(self, *args, **kwargs):
|
def parse_args(self,
|
||||||
|
*args,
|
||||||
|
valid_mandatory=True,
|
||||||
|
**kwargs):
|
||||||
kwargs['namespace'] = TiramisuNamespace(self.config)
|
kwargs['namespace'] = TiramisuNamespace(self.config)
|
||||||
try:
|
try:
|
||||||
namespaces = super().parse_args(*args, **kwargs)
|
namespaces = super().parse_args(*args, **kwargs)
|
||||||
|
@ -236,13 +239,14 @@ class TiramisuCmdlineParser(ArgumentParser):
|
||||||
self.error('the following arguments are required: {}'.format(name))
|
self.error('the following arguments are required: {}'.format(name))
|
||||||
else:
|
else:
|
||||||
self.error('unrecognized arguments: {}'.format(name))
|
self.error('unrecognized arguments: {}'.format(name))
|
||||||
for key in self.config.value.mandatory():
|
if valid_mandatory:
|
||||||
if self.fullpath or '.' not in key:
|
for key in self.config.value.mandatory():
|
||||||
name = key
|
if self.fullpath or '.' not in key:
|
||||||
else:
|
name = key
|
||||||
name = key.rsplit('.', 1)[1]
|
else:
|
||||||
args = self._gen_argument(name, self.config.option(key).property.get())
|
name = key.rsplit('.', 1)[1]
|
||||||
self.error('the following arguments are required: {}'.format(args))
|
args = self._gen_argument(name, self.config.option(key).property.get())
|
||||||
|
self.error('the following arguments are required: {}'.format(args))
|
||||||
return namespaces
|
return namespaces
|
||||||
|
|
||||||
def format_usage(self,
|
def format_usage(self,
|
||||||
|
|
Loading…
Reference in a new issue