Added logic to answer questions of new command dialog by flag arguments

This commit is contained in:
Sven Heidemann 2022-05-26 21:18:57 +02:00
parent 15d938b172
commit d23ea86ccf
2 changed files with 36 additions and 16 deletions

View File

@ -169,22 +169,22 @@ class NewService(CommandABC):
Gets project information's from user Gets project information's from user
:return: :return:
""" """
if not is_unittest: if self._use_application_api or self._use_startup or self._use_service_providing or self._use_async:
result = Console.read('Do you want to use application base? (y/n) ') Console.set_foreground_color(ForegroundColorEnum.default)
if result.lower() == 'y': Console.write_line('Skipping question due to given flags')
self._use_application_api = True return
result = Console.read('Do you want to use startup? (y/n) ') if not is_unittest:
if result.lower() == 'y': self._use_application_api = Console.read('Do you want to use application base? (y/n) ').lower() == 'y'
self._use_startup = True
else: if not is_unittest and self._use_application_api:
result = Console.read('Do you want to use service providing? (y/n) ') self._use_startup = Console.read('Do you want to use startup? (y/n) ').lower() == 'y'
if result.lower() == 'y':
self._use_service_providing = True if not is_unittest and not self._use_application_api:
self._use_service_providing = Console.read('Do you want to use service providing? (y/n) ').lower() == 'y'
result = Console.read('Do you want to use async? (y/n) ')
if result.lower() == 'y': if not self._use_async:
self._use_async = True self._use_async = Console.read('Do you want to use async? (y/n) ').lower() == 'y'
Console.set_foreground_color(ForegroundColorEnum.default) Console.set_foreground_color(ForegroundColorEnum.default)
@ -276,6 +276,22 @@ class NewService(CommandABC):
:param args: :param args:
:return: :return:
""" """
if 'async' in args:
self._use_async = True
args.remove('async')
if 'application-base' in args:
self._use_application_api = True
args.remove('application-base')
if 'startup' in args:
self._use_startup = True
args.remove('startup')
if 'service-providing' in args:
self._use_service_providing = True
args.remove('service-providing')
console = self._config.get_configuration(ProjectTypeEnum.console.value) console = self._config.get_configuration(ProjectTypeEnum.console.value)
library = self._config.get_configuration(ProjectTypeEnum.library.value) library = self._config.get_configuration(ProjectTypeEnum.library.value)
unittest = self._config.get_configuration(ProjectTypeEnum.unittest.value) unittest = self._config.get_configuration(ProjectTypeEnum.unittest.value)

View File

@ -86,7 +86,11 @@ class StartupArgumentExtension(StartupExtensionABC):
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'new', ['n', 'N'], NewService, True) \ config.create_console_argument(ArgumentTypeEnum.Executable, '', 'new', ['n', 'N'], NewService, True) \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'console', ['c', 'C'], ' ') \ .add_console_argument(ArgumentTypeEnum.Variable, '', 'console', ['c', 'C'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'library', ['l', 'L'], ' ') \ .add_console_argument(ArgumentTypeEnum.Variable, '', 'library', ['l', 'L'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'unittest', ['ut', 'UT'], ' ') .add_console_argument(ArgumentTypeEnum.Variable, '', 'unittest', ['ut', 'UT'], ' ') \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'async', ['a', 'A']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'application-base', ['ab', 'AB']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'startup', ['s', 'S']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'service-providing', ['sp', 'SP'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'publish', ['p', 'P'], PublishService, True, validators=[ProjectValidator]) config.create_console_argument(ArgumentTypeEnum.Executable, '', 'publish', ['p', 'P'], PublishService, True, validators=[ProjectValidator])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'remove', ['r', 'R'], RemoveService, True, validators=[WorkspaceValidator]) \ config.create_console_argument(ArgumentTypeEnum.Executable, '', 'remove', ['r', 'R'], RemoveService, True, validators=[WorkspaceValidator]) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S']) .add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])