Bugfixes and improved setup logic

This commit is contained in:
2020-12-15 23:10:31 +01:00
parent 8c531ebd11
commit 97b4f516a8
6 changed files with 41 additions and 6 deletions

2
src/MANIFEST.in Normal file
View File

@@ -0,0 +1,2 @@
include ../ README
recursive-include sh_edraft *.txt

View File

@@ -8,6 +8,7 @@ setuptools.setup(
license='MIT',
author='Sven Heidemann',
author_email='edraft.sh@gmail.com',
include_package_data=True,
description='sh-edraft python common lib',
python_requires='>=3.8',
install_requires=[

View File

@@ -10,6 +10,7 @@ class CLI:
def setup(self):
self._commands[CLICommands.new.__name__] = CLICommands.new
self._commands[CLICommands.help.__name__] = CLICommands.help
def main(self):
args = sys.argv[1:]

View File

@@ -5,7 +5,8 @@ class CLICommands:
@classmethod
def new(cls, args: list[str]):
if not os.path.isdir(f'./templates/{args[0]}'):
rel_path = os.path.dirname(__file__)
if not os.path.isdir(f'{rel_path}/templates/{args[0]}'):
cls.unexpected_command(args[0])
sub_args = args[1:]
@@ -13,7 +14,11 @@ class CLICommands:
if len(sub_args) != 1:
cls.unexpected_argument(sub_args[1])
full_path = sub_args[0]
if not (sub_args[0].startswith('.') or sub_args[0].startswith('/')):
full_path = f'./{sub_args[0]}'
else:
full_path = sub_args[0]
name = os.path.basename(full_path)
path = os.path.dirname(full_path)
@@ -24,7 +29,7 @@ class CLICommands:
if not os.path.isdir(full_path):
os.makedirs(full_path)
for r, d, f in os.walk(f'./templates/{args[0]}'):
for r, d, f in os.walk(f'{rel_path}/templates/{args[0]}'):
for file in f:
template_content = ''
with open(f'{r}/{file}') as template:
@@ -71,7 +76,7 @@ class CLICommands:
pyfile.close()
@staticmethod
def help():
def help(*args):
print('Commands:')
@classmethod