From 47a6796e1cec6d38771c4f39cffe1705f4aaac8b Mon Sep 17 00:00:00 2001 From: p7mj Date: Fri, 24 Apr 2026 08:42:19 -0400 Subject: [PATCH] Kind of shi that half works --- bugpy-mos-0.py | 33 +++++++++++++++++++++------- config/pointerfile.txt | 9 +++++++- hi.txt | 0 scripts/list_files/list_files.py | 16 ++++++++------ scripts/make_file/__init__.py | 0 scripts/make_file/config.txt | 0 scripts/make_file/make_file.py | 10 +++++++++ scripts/remove/__init__.py | 0 scripts/remove/config.txt | 0 scripts/remove/remove.py | 5 +++++ scripts/say_greeting/config.txt | 0 scripts/say_greeting/say_greeting.py | 2 +- scripts/touch_file/__init__.py | 0 scripts/touch_file/config.txt | 0 scripts/touch_file/touch_file.py | 6 +++++ 15 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 hi.txt create mode 100644 scripts/make_file/__init__.py create mode 100644 scripts/make_file/config.txt create mode 100644 scripts/make_file/make_file.py create mode 100644 scripts/remove/__init__.py create mode 100644 scripts/remove/config.txt create mode 100644 scripts/remove/remove.py create mode 100644 scripts/say_greeting/config.txt create mode 100644 scripts/touch_file/__init__.py create mode 100644 scripts/touch_file/config.txt create mode 100644 scripts/touch_file/touch_file.py diff --git a/bugpy-mos-0.py b/bugpy-mos-0.py index 5590869..da01d64 100644 --- a/bugpy-mos-0.py +++ b/bugpy-mos-0.py @@ -1,11 +1,20 @@ # BUGS-Python Mock Operating System Version 0 "Devvie" from scripts.list_files import list_files from scripts.say_greeting import say_greeting +from scripts.make_file import make_file +from scripts.touch_file import touch_file +from scripts.remove import remove from pathlib import Path # Shitty test # list_files.main() +verbose = 1 + +def verbose(strings): + if verbose == 1: + print(str(strings)) + def get_config_line(keyword): # 1. Find the project root relative to this script @@ -27,24 +36,32 @@ def get_config_line(keyword): return None # Return None if keyword isn't found -def match_command(command): +def match_command(command, args_list): if command == "list_files": - list_files.main() + list_files.main(args_list) elif command == "say_greeting": - say_greeting.main() + say_greeting.main(args_list) + elif command == "touch_file": + touch_file.main(args_list) + elif command == "make_file": + make_file.main(args_list) + elif command == "remove": + remove.main(args_list) # use if else if else if else if to match the output def cmdrun(keyword): - get_config_result = get_config_line(keyword) + parsed = keyword.split() + get_config_result = get_config_line(parsed[0]) + print(get_config_result) if not get_config_result == None: - match_command(get_config_result[1]) + match_command(get_config_result[1], parsed[1:]) + return True else: return False -print(get_config_line("dir")) - if __name__ == "__main__": print("BUGPy-mOS 0 \"Devvie\"") while True: inputs = input("BUGS > ") - cmdrun(inputs) \ No newline at end of file + if not cmdrun(inputs): + print("BAD COMMAND") \ No newline at end of file diff --git a/config/pointerfile.txt b/config/pointerfile.txt index e0a044d..4f2ae3a 100644 --- a/config/pointerfile.txt +++ b/config/pointerfile.txt @@ -5,4 +5,11 @@ hi: say_greeting hello: say_greeting greeting: say_greeting greetings: say_greeting -say_greeting: say_greeting \ No newline at end of file +say_greeting: say_greeting +mk: make_file +New-Item: make_file +make_file: make_file +touch: touch_file +touch_file: touch_file +rm: remove +remove: remove \ No newline at end of file diff --git a/hi.txt b/hi.txt new file mode 100644 index 0000000..e69de29 diff --git a/scripts/list_files/list_files.py b/scripts/list_files/list_files.py index 0aace10..d662b7e 100644 --- a/scripts/list_files/list_files.py +++ b/scripts/list_files/list_files.py @@ -1,15 +1,17 @@ from pathlib import Path -def main(): +def main(args): # Set the directory path script_dir = Path(__file__).resolve().parent dir_path = Path("") # Use the current script's directory or specify a path base_path = Path(__file__).resolve().parent - - for entry in dir_path.iterdir(): - if entry.is_dir(): - print(f"[FOLDER] {entry.name}") - elif entry.is_file(): - print(f"[FILE] {entry.name}") \ No newline at end of file + if args == []: + for entry in dir_path.iterdir(): + if entry.is_dir(): + print(f"[FOLDER] {entry.name}") + elif entry.is_file(): + print(f"[FILE] {entry.name}") + elif args == ["--help"] or args == ["-h"]: + print("Bro is lazy on doing this help section") diff --git a/scripts/make_file/__init__.py b/scripts/make_file/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/make_file/config.txt b/scripts/make_file/config.txt new file mode 100644 index 0000000..e69de29 diff --git a/scripts/make_file/make_file.py b/scripts/make_file/make_file.py new file mode 100644 index 0000000..2fb36e9 --- /dev/null +++ b/scripts/make_file/make_file.py @@ -0,0 +1,10 @@ +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 \ No newline at end of file diff --git a/scripts/remove/__init__.py b/scripts/remove/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/remove/config.txt b/scripts/remove/config.txt new file mode 100644 index 0000000..e69de29 diff --git a/scripts/remove/remove.py b/scripts/remove/remove.py new file mode 100644 index 0000000..eb98dcc --- /dev/null +++ b/scripts/remove/remove.py @@ -0,0 +1,5 @@ +from pathlib import Path + +def main(args): + for item in args: + Path(args).unlink(missing_ok=True) # missing_ok=True prevents error if file is missing diff --git a/scripts/say_greeting/config.txt b/scripts/say_greeting/config.txt new file mode 100644 index 0000000..e69de29 diff --git a/scripts/say_greeting/say_greeting.py b/scripts/say_greeting/say_greeting.py index 6d55559..20c42e0 100644 --- a/scripts/say_greeting/say_greeting.py +++ b/scripts/say_greeting/say_greeting.py @@ -1,2 +1,2 @@ -def main(): +def main(arg): print("Hi!") \ No newline at end of file diff --git a/scripts/touch_file/__init__.py b/scripts/touch_file/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/touch_file/config.txt b/scripts/touch_file/config.txt new file mode 100644 index 0000000..e69de29 diff --git a/scripts/touch_file/touch_file.py b/scripts/touch_file/touch_file.py new file mode 100644 index 0000000..f9bce34 --- /dev/null +++ b/scripts/touch_file/touch_file.py @@ -0,0 +1,6 @@ +from pathlib import Path + +def main(args): + for target in args: + path = Path(target) + path.touch(exist_ok=True) \ No newline at end of file