Adding presets in a fucked up way D:< AAAAAND adding some output for the user :3
This commit is contained in:
1 parent
7ad6c893c7
commit
21f0e81856
1 file changed
+22
-2
@@ -4,12 +4,13 @@ import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
if __name__ == 'main' :
|
||||
parser = argparse.ArgumentParser(description="A python project preparer for Linux")
|
||||
if __name__ == '__main__' :
|
||||
parser = argparse.ArgumentParser(description="A Python project preparer for Linux")
|
||||
|
||||
parser.add_argument('-n','--name',default='NewProject',help='The project name')
|
||||
parser.add_argument('-p','--path',default=False,help='The path to create the project in')
|
||||
parser.add_argument('-f','--filename',default='main.py',help="Initial file name")
|
||||
parser.add_argument('--file-preset',default='',help='Choose a preset for the init file: print | class | import')
|
||||
parser.add_argument('-g','--git',action='store_true',help='If "git init" should be used')
|
||||
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
@@ -39,10 +40,29 @@ if __name__ == 'main' :
|
||||
path = Path(path.absolute().as_posix() + f"/{args.name}")
|
||||
|
||||
path.mkdir()
|
||||
print('Directory was created.')
|
||||
|
||||
file = Path(path.absolute().as_posix() + f"/{args.filename}")
|
||||
file.touch(mode=0o750)
|
||||
print('File was created.')
|
||||
|
||||
match args.file_preset :
|
||||
case 'print' :
|
||||
file.write_text('print("This was made with the Linux Python preparer")')
|
||||
print(f"Preset {args.file_preset} was implemented.")
|
||||
case 'class' :
|
||||
file.write_text('class NewClass :\n\t\n\tdef __init__() :\n\t\tpass')
|
||||
print(f"Preset {args.file_preset} was implemented.")
|
||||
case 'import' :
|
||||
file.write_text('import pathlib\nimport os\nimport subprocess')
|
||||
print(f"Preset {args.file_preset} was implemented.")
|
||||
case '' :
|
||||
pass
|
||||
case _:
|
||||
print('Preset does not exist.')
|
||||
|
||||
os.chdir(path.absolute())
|
||||
if args.git :
|
||||
subprocess.run(['git','init'])
|
||||
|
||||
print('The process was completed successfully.')
|
||||
Reference in new issue
Block a user