Improved path and name handling in new command
This commit is contained in:
parent
2b5c75cc67
commit
f6fc5d09e7
@ -13,10 +13,14 @@ class String:
|
|||||||
:param name:
|
:param name:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
# convert to train-case to CamelCase
|
||||||
|
if '-' in name:
|
||||||
|
name = ''.join(word.title() for word in name.split('-'))
|
||||||
|
|
||||||
pattern1 = re.compile(r'(.)([A-Z][a-z]+)')
|
pattern1 = re.compile(r'(.)([A-Z][a-z]+)')
|
||||||
pattern2 = re.compile(r'([a-z0-9])([A-Z])')
|
pattern2 = re.compile(r'([a-z0-9])([A-Z])')
|
||||||
file_name = re.sub(pattern1, r'\1_\2', name)
|
file_name = re.sub(pattern1, r'\1_\2', name)
|
||||||
return re.sub(pattern2, r'\1_\2', file_name).lower().replace('-', '_')
|
return re.sub(pattern2, r'\1_\2', file_name).lower()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def first_to_upper(string: str) -> str:
|
def first_to_upper(string: str) -> str:
|
||||||
|
@ -129,8 +129,12 @@ class ConsoleBuilder:
|
|||||||
)
|
)
|
||||||
|
|
||||||
for template in templates:
|
for template in templates:
|
||||||
|
divider = ''
|
||||||
|
if not template.path.endswith('/'):
|
||||||
|
divider = '/'
|
||||||
|
|
||||||
Console.spinner(
|
Console.spinner(
|
||||||
f'Creating {proj_name}/{template.path}{template.name}',
|
f'Creating {proj_name}/{template.path}{divider}{template.name}',
|
||||||
TemplateBuilder.build,
|
TemplateBuilder.build,
|
||||||
project_path,
|
project_path,
|
||||||
template,
|
template,
|
||||||
|
@ -129,8 +129,12 @@ class LibraryBuilder:
|
|||||||
)
|
)
|
||||||
|
|
||||||
for template in templates:
|
for template in templates:
|
||||||
|
divider = ''
|
||||||
|
if not template.path.endswith('/'):
|
||||||
|
divider = '/'
|
||||||
|
|
||||||
Console.spinner(
|
Console.spinner(
|
||||||
f'Creating {proj_name}/{template.path}{template.name}',
|
f'Creating {proj_name}/{template.path}{divider}{template.name}',
|
||||||
TemplateBuilder.build,
|
TemplateBuilder.build,
|
||||||
project_path,
|
project_path,
|
||||||
template,
|
template,
|
||||||
|
Loading…
Reference in New Issue
Block a user