Kind of shi that half works

This commit is contained in:
2026-04-24 08:42:19 -04:00
parent 74abef1b9f
commit 47a6796e1c
15 changed files with 64 additions and 17 deletions

View File

@@ -1,11 +1,20 @@
# BUGS-Python Mock Operating System Version 0 "Devvie" # BUGS-Python Mock Operating System Version 0 "Devvie"
from scripts.list_files import list_files from scripts.list_files import list_files
from scripts.say_greeting import say_greeting 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 from pathlib import Path
# Shitty test # Shitty test
# list_files.main() # list_files.main()
verbose = 1
def verbose(strings):
if verbose == 1:
print(str(strings))
def get_config_line(keyword): def get_config_line(keyword):
# 1. Find the project root relative to this script # 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 return None # Return None if keyword isn't found
def match_command(command): def match_command(command, args_list):
if command == "list_files": if command == "list_files":
list_files.main() list_files.main(args_list)
elif command == "say_greeting": 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 # use if else if else if else if to match the output
def cmdrun(keyword): 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: if not get_config_result == None:
match_command(get_config_result[1]) match_command(get_config_result[1], parsed[1:])
return True
else: else:
return False return False
print(get_config_line("dir"))
if __name__ == "__main__": if __name__ == "__main__":
print("BUGPy-mOS 0 \"Devvie\"") print("BUGPy-mOS 0 \"Devvie\"")
while True: while True:
inputs = input("BUGS > ") inputs = input("BUGS > ")
cmdrun(inputs) if not cmdrun(inputs):
print("BAD COMMAND")

View File

@@ -6,3 +6,10 @@ hello: say_greeting
greeting: say_greeting greeting: say_greeting
greetings: say_greeting greetings: say_greeting
say_greeting: say_greeting 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

0
hi.txt Normal file
View File

View File

@@ -1,15 +1,17 @@
from pathlib import Path from pathlib import Path
def main(): def main(args):
# Set the directory path # Set the directory path
script_dir = Path(__file__).resolve().parent script_dir = Path(__file__).resolve().parent
dir_path = Path("") dir_path = Path("")
# Use the current script's directory or specify a path # Use the current script's directory or specify a path
base_path = Path(__file__).resolve().parent base_path = Path(__file__).resolve().parent
if args == []:
for entry in dir_path.iterdir(): for entry in dir_path.iterdir():
if entry.is_dir(): if entry.is_dir():
print(f"[FOLDER] {entry.name}") print(f"[FOLDER] {entry.name}")
elif entry.is_file(): elif entry.is_file():
print(f"[FILE] {entry.name}") print(f"[FILE] {entry.name}")
elif args == ["--help"] or args == ["-h"]:
print("Bro is lazy on doing this help section")

View File

View File

View File

@@ -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

View File

View File

5
scripts/remove/remove.py Normal file
View File

@@ -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

View File

View File

@@ -1,2 +1,2 @@
def main(): def main(arg):
print("Hi!") print("Hi!")

View File

View File

View File

@@ -0,0 +1,6 @@
from pathlib import Path
def main(args):
for target in args:
path = Path(target)
path.touch(exist_ok=True)