config: add ask_values and execute_callback parameters to parse_arguments_options
This commit is contained in:
parent
2e829c4cc3
commit
6601891f9d
1 changed files with 11 additions and 3 deletions
|
@ -752,7 +752,8 @@ class Config:
|
|||
|
||||
return self.options_parser
|
||||
|
||||
def parse_arguments_options(self, argv=None, parser=None, create=True, exit_after_created=True):
|
||||
def parse_arguments_options(self, argv=None, parser=None, create=True, ask_values=True,
|
||||
exit_after_created=True, execute_callback=True):
|
||||
"""
|
||||
Parse arguments options
|
||||
|
||||
|
@ -761,8 +762,12 @@ class Config:
|
|||
(default: generated by self.get_arguments_parser())
|
||||
:param create: If True, configuration file will be created if it does not exits
|
||||
(default: True)
|
||||
:param ask_values: If True, ask user to enter valor of each configuration options
|
||||
(default: True)
|
||||
:param exit_after_created: If True, script will end after configuration file
|
||||
creation (default: True)
|
||||
creation (default: True)
|
||||
:param execute_callback: Sections's loaded callbacks will be executed only if True
|
||||
(default: True)
|
||||
"""
|
||||
parser = parser if parser else self.get_arguments_parser()
|
||||
argcomplete.autocomplete(parser)
|
||||
|
@ -778,6 +783,8 @@ class Config:
|
|||
"Configuration file is missing, generate it (%s)",
|
||||
options.config
|
||||
)
|
||||
if ask_values:
|
||||
self.ask_values(set_it=True)
|
||||
self.save(options.config)
|
||||
if exit_after_created:
|
||||
sys.exit(0)
|
||||
|
@ -802,7 +809,8 @@ class Config:
|
|||
console_handler = logging.StreamHandler(sys.stdout)
|
||||
logging.getLogger().addHandler(console_handler)
|
||||
|
||||
self._loaded()
|
||||
if execute_callback:
|
||||
self._loaded()
|
||||
|
||||
return options
|
||||
|
||||
|
|
Loading…
Reference in a new issue