commit 2747c451de2dc9bee0c2d4dbec48a9f0e2488264 Author: Kairoto Date: Wed Jul 8 23:56:27 2026 +0200 Initial commit diff --git a/main.py b/main.py new file mode 100644 index 0000000..0fd8b3f --- /dev/null +++ b/main.py @@ -0,0 +1,43 @@ +import subprocess +from pathlib import Path +import os +import sys +import argparse + +parser = argparse.ArgumentParser(description="A python project preparator for Linux") + +parser.add_argument('-n','--name',action='store_const',default='NewProject',const='NewProject',help='The project name') +parser.add_argument('-p','--path',action='store_const',default=False,const=False,help='The path to create the project in') +parser.add_argument('-f','--filename',action='store_const',default='main.py',const='main.py',help="Initial file name") +parser.add_argument('-g','--git',action='store_true',help='If "git init" should be used') + +args = parser.parse_args(sys.argv[1:]) + +if not args.path : + path = Path().cwd() +else : + dest = args.path if args.path[0]=='~' else Path.home() + args.path[1:] + path = Path(dest+f"/{args.name}") + +if not path.exists() and path.is_file() : + raise Exception('Path does not exist') + +counter = 0 + +for subpath in path.iterdir() : + if subpath.name == args.name : + counter += 1 + +if counter != 0 : + path = Path(path.absolute().as_posix() + f"/{args.name}" + str(counter)) +else : + path = Path(path.absolute().as_posix() + f"/{args.name}") + +path.mkdir() + +file = Path(path.absolute().as_posix() + f"/{args.filename}") +file.touch(mode=0o750) + +os.chdir(path.absolute()) +if args.git : + subprocess.run(['git','init']) \ No newline at end of file