Added help and exit

This commit is contained in:
2026-04-27 12:15:58 -04:00
parent 47a6796e1c
commit 7b2bb509ec
13 changed files with 103 additions and 23 deletions

0
scripts/exit/__init__.py Normal file
View File

4
scripts/exit/exit.py Normal file
View File

@@ -0,0 +1,4 @@
import sys
def main(args):
print("Exiting BUGPy!")
sys.exit(0)

0
scripts/help/__init__.py Normal file
View File

2
scripts/help/help.py Normal file
View File

@@ -0,0 +1,2 @@
def main(args):
print("An unfinished help section! Yay")

View File

@@ -14,4 +14,6 @@ def main(args):
elif entry.is_file():
print(f"[FILE] {entry.name}")
elif args == ["--help"] or args == ["-h"]:
print("Bro is lazy on doing this help section")
print("list_files: Bro is lazy on doing this help section")
else:
print("list_files: Invalid arguments, try using none?")

View File

@@ -1,10 +1,14 @@
from pathlib import Path
def main(args):
for target in args:
path = Path(target)
if path.exists():
print(f'"{target}" already exists.')
continue
path.write_text("") # Pure creation
if args == []:
print("make_file: no arguments were given.")
elif args == ["-h"] or args == ["--help"]:
print("make_file: bro is lazy do this later")
else:
for target in args:
path = Path(target)
if path.exists():
print(f'make_file: "{target}" already exists.')
continue
path.write_text("")

View File

@@ -1,5 +1,33 @@
from pathlib import Path
import shutil
def main(args):
for item in args:
Path(args).unlink(missing_ok=True) # missing_ok=True prevents error if file is missing
if not args:
print("remove: no arguments were given")
return
# Check for the -rf flag
recursive = False
if "-rf" in args:
recursive = True
args.remove("-rf") # Remove flag from list so only paths remain
if args == ["-h"] or args == ["--help"]:
print("remove: Use -rf to delete directories and their contents.")
else:
for item in args:
path = Path(item)
if not path.exists():
continue # 'force' usually means ignore non-existent files
try:
if path.is_dir():
if recursive:
shutil.rmtree(path) # This is the "recursive" part
else:
print(f"remove: cannot remove '{item}': Is a directory")
else:
path.unlink() # Delete individual file
except Exception as e:
print(f"remove: error deleting {item}: {e}")

View File

@@ -1,2 +1,5 @@
def main(arg):
print("Hi!")
def main(args):
if args == []:
print("say_greeting: Hi!")
elif args == ["-h"] or args == ["--help"]:
print("say_greeting: Bro is lazy to make this pointless help section")

View File

@@ -1,6 +1,11 @@
from pathlib import Path
def main(args):
for target in args:
path = Path(target)
path.touch(exist_ok=True)
if args == []:
print("touch_file: no arguments were given")
elif args == ["-h"] or args == ["--help"]:
print("touch_file: bro was lazy")
else:
for target in args:
path = Path(target)
path.touch(exist_ok=True)