Fixed cpl help #137
This commit is contained in:
parent
f6cc3a7ddf
commit
b63bf41294
@ -28,51 +28,28 @@ class GenerateService(CommandABC):
|
|||||||
self._config = configuration
|
self._config = configuration
|
||||||
self._workspace = workspace
|
self._workspace = workspace
|
||||||
|
|
||||||
self._schematics = {}
|
|
||||||
# "abc": {
|
|
||||||
# "Upper": "ABC",
|
|
||||||
# "Template": ABCTemplate
|
|
||||||
# },
|
|
||||||
# "class": {
|
|
||||||
# "Upper": "Class",
|
|
||||||
# "Template": ClassTemplate
|
|
||||||
# },
|
|
||||||
# "enum": {
|
|
||||||
# "Upper": "Enum",
|
|
||||||
# "Template": EnumTemplate
|
|
||||||
# },
|
|
||||||
# "pipe": {
|
|
||||||
# "Upper": "Pipe",
|
|
||||||
# "Template": PipeTemplate
|
|
||||||
# },
|
|
||||||
# "service": {
|
|
||||||
# "Upper": "Service",
|
|
||||||
# "Template": ServiceTemplate
|
|
||||||
# },
|
|
||||||
# "settings": {
|
|
||||||
# "Upper": "Settings",
|
|
||||||
# "Template": ConfigModelTemplate
|
|
||||||
# },
|
|
||||||
# "test_case": {
|
|
||||||
# "Upper": "TestCase",
|
|
||||||
# "Template": TestCaseTemplate
|
|
||||||
# },
|
|
||||||
# "thread": {
|
|
||||||
# "Upper": "Thread",
|
|
||||||
# "Template": ThreadTemplate
|
|
||||||
# },
|
|
||||||
# "validator": {
|
|
||||||
# "Upper": "Validator",
|
|
||||||
# "Template": ValidatorTemplate
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
self._config = configuration
|
self._config = configuration
|
||||||
self._env = self._config.environment
|
self._env = self._config.environment
|
||||||
|
self._schematics = {}
|
||||||
|
|
||||||
|
self._read_custom_schematics_from_path(self._env.runtime_directory)
|
||||||
|
self._read_custom_schematics_from_path(self._env.working_directory)
|
||||||
|
for schematic in GenerateSchematicABC.__subclasses__():
|
||||||
|
schematic.register()
|
||||||
|
|
||||||
|
self._schematics = SchematicCollection.get_schematics()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def help_message(self) -> str:
|
def help_message(self) -> str:
|
||||||
return textwrap.dedent("""\
|
schematics = []
|
||||||
|
for schematic in self._schematics:
|
||||||
|
aliases = '|'.join(self._schematics[schematic]['Aliases'])
|
||||||
|
schematic_str = schematic
|
||||||
|
if len(aliases) > 0:
|
||||||
|
schematic_str = f'{schematic} ({aliases})'
|
||||||
|
|
||||||
|
schematics.append(schematic_str)
|
||||||
|
help_msg = textwrap.dedent("""\
|
||||||
Generate a file based on schematic.
|
Generate a file based on schematic.
|
||||||
Usage: cpl generate <schematic> <name>
|
Usage: cpl generate <schematic> <name>
|
||||||
|
|
||||||
@ -80,41 +57,11 @@ class GenerateService(CommandABC):
|
|||||||
schematic: The schematic to generate.
|
schematic: The schematic to generate.
|
||||||
name: The name of the generated file
|
name: The name of the generated file
|
||||||
|
|
||||||
Schematics:
|
Schematics:""")
|
||||||
abc
|
|
||||||
class
|
|
||||||
enum
|
|
||||||
pipe
|
|
||||||
service
|
|
||||||
settings
|
|
||||||
test_case
|
|
||||||
thread
|
|
||||||
validator
|
|
||||||
""")
|
|
||||||
|
|
||||||
@staticmethod
|
for schematic in schematics:
|
||||||
def _help(message: str):
|
help_msg += f'\n {schematic}'
|
||||||
"""
|
return help_msg
|
||||||
Internal help output
|
|
||||||
:param message:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
Console.error(message)
|
|
||||||
|
|
||||||
schematics = [
|
|
||||||
'abc (a|A)',
|
|
||||||
'class (c|C)',
|
|
||||||
'enum (e|E)',
|
|
||||||
'pipe (p|P)',
|
|
||||||
'service (s|S)',
|
|
||||||
'settings (st|ST)',
|
|
||||||
'test-case (tc|TC)',
|
|
||||||
'thread (t|T)',
|
|
||||||
'validator (v|V)'
|
|
||||||
]
|
|
||||||
Console.write_line('Available Schematics:')
|
|
||||||
for name in schematics:
|
|
||||||
Console.write(f'\n\t{name} ')
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _create_file(file_path: str, value: str):
|
def _create_file(file_path: str, value: str):
|
||||||
@ -220,12 +167,6 @@ class GenerateService(CommandABC):
|
|||||||
:param args:
|
:param args:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
self._read_custom_schematics_from_path(self._env.runtime_directory)
|
|
||||||
self._read_custom_schematics_from_path(self._env.working_directory)
|
|
||||||
for schematic in GenerateSchematicABC.__subclasses__():
|
|
||||||
schematic.register()
|
|
||||||
self._schematics = SchematicCollection.get_schematics()
|
|
||||||
|
|
||||||
schematic = None
|
schematic = None
|
||||||
value = None
|
value = None
|
||||||
for s in self._schematics:
|
for s in self._schematics:
|
||||||
@ -241,8 +182,8 @@ class GenerateService(CommandABC):
|
|||||||
value = args[1]
|
value = args[1]
|
||||||
|
|
||||||
if schematic is None:
|
if schematic is None:
|
||||||
self._help('Usage: cpl generate <schematic> [options]')
|
Console.error(f'Schematic not found')
|
||||||
Console.write_line()
|
Console.write_line(self.help_message)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
name = value
|
name = value
|
||||||
|
@ -67,29 +67,11 @@ class NewService(CommandABC):
|
|||||||
name Name of the workspace or the project
|
name Name of the workspace or the project
|
||||||
|
|
||||||
Types:
|
Types:
|
||||||
console
|
console (c|C)
|
||||||
library
|
library (l|L)
|
||||||
unittest
|
unittest (ut|UT)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _help(message: str):
|
|
||||||
"""
|
|
||||||
Internal help output
|
|
||||||
:param message:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
Console.error(message)
|
|
||||||
|
|
||||||
schematics = [
|
|
||||||
'console (c|C) <name>',
|
|
||||||
'library (l|L) <name>',
|
|
||||||
'unittest (ut|UT) <name>',
|
|
||||||
]
|
|
||||||
Console.write_line('Available Schematics:')
|
|
||||||
for name in schematics:
|
|
||||||
Console.write(f'\n\t{name} ')
|
|
||||||
|
|
||||||
def _create_project_settings(self):
|
def _create_project_settings(self):
|
||||||
self._rel_path = os.path.dirname(self._name)
|
self._rel_path = os.path.dirname(self._name)
|
||||||
self._project_dict = {
|
self._project_dict = {
|
||||||
@ -369,5 +351,6 @@ class NewService(CommandABC):
|
|||||||
self._create_venv()
|
self._create_venv()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self._help('Usage: cpl new <schematic> [options]')
|
Console.error(f'Project type not found')
|
||||||
|
Console.write_line(self.help_message)
|
||||||
return
|
return
|
||||||
|
@ -7,4 +7,4 @@ class ArgumentExecutableABC(ABC):
|
|||||||
def __init__(self): pass
|
def __init__(self): pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def execute(self, args: list[str]): pass
|
def run(self, args: list[str]): pass
|
||||||
|
@ -341,7 +341,7 @@ class Configuration(ConfigurationABC):
|
|||||||
continue
|
continue
|
||||||
self._additional_arguments.append(arg)
|
self._additional_arguments.append(arg)
|
||||||
|
|
||||||
cmd.execute(self._additional_arguments)
|
cmd.run(self._additional_arguments)
|
||||||
self._handle_pre_or_post_executables(False, exe, services)
|
self._handle_pre_or_post_executables(False, exe, services)
|
||||||
prevent = exe.prevent_next_executable
|
prevent = exe.prevent_next_executable
|
||||||
success = True
|
success = True
|
||||||
|
Loading…
Reference in New Issue
Block a user