From 5bc61e30a6da3ca4df386f60bb17f29fa52baf20 Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Fri, 23 Jan 2026 16:38:53 +1100 Subject: [PATCH] fixed numerous bugs --- fileio/SUMMARY.md | 7 +++++++ fileio/docs/read.md | 17 +++++++++++++++++ fileio/docs/write.md | 17 +++++++++++++++++ fileio/mineral.ini | 5 +++++ mineral.tar | Bin 0 -> 2055 bytes src/build.py | 15 +++++++++++++-- src/main.py | 2 +- src/publish.py | 15 +++++++-------- stdlib/SUMMARY.md | 4 ++++ stdlib/mineral.ini | 10 ++++++++++ 10 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 fileio/SUMMARY.md create mode 100644 fileio/docs/read.md create mode 100644 fileio/docs/write.md create mode 100644 fileio/mineral.ini create mode 100644 mineral.tar create mode 100644 stdlib/SUMMARY.md create mode 100644 stdlib/mineral.ini diff --git a/fileio/SUMMARY.md b/fileio/SUMMARY.md new file mode 100644 index 0000000..362240e --- /dev/null +++ b/fileio/SUMMARY.md @@ -0,0 +1,7 @@ +# fileio +Perform file system operations. + +## Files +- [file_Read](docs/read.md) +- [file_Write](docs/write.md) + diff --git a/fileio/docs/read.md b/fileio/docs/read.md new file mode 100644 index 0000000..600ea90 --- /dev/null +++ b/fileio/docs/read.md @@ -0,0 +1,17 @@ +# file_Read +Open a file and return the contents in `r` mode. + +## Arguments +- path (string): Path to the file you want to read + +## Returns +- content (string): Contents of the file + +## Raises +- `FileError`: Raised if the file doesn't exist or there was an error allocating memory for the file + +## Example +```python +call !file_Read "my_file.txt" &contents +println $contents +``` diff --git a/fileio/docs/write.md b/fileio/docs/write.md new file mode 100644 index 0000000..f74ad32 --- /dev/null +++ b/fileio/docs/write.md @@ -0,0 +1,17 @@ +# file_Write +Open a file and overwrite its contents with the provided string in `w` mode. + +## Arguments +- path (string): Path to the file you want to write to + +## Returns +- success (boolean): Whether writing to the file succeeded or not + +## Raises +- `FileError`: Raised if the file doesn't exist + +## Example +```python +call !file_Read "my_file.txt" &contents +println $contents +``` diff --git a/fileio/mineral.ini b/fileio/mineral.ini new file mode 100644 index 0000000..ce5e55b --- /dev/null +++ b/fileio/mineral.ini @@ -0,0 +1,5 @@ +[package] +description=Provides file I/O support for Ground +version=1.2.0 + +[dependencies] diff --git a/mineral.tar b/mineral.tar new file mode 100644 index 0000000000000000000000000000000000000000..185da08fae2f9712d8e23eecd1f3f5bfb05cd878 GIT binary patch literal 2055 zcmV+i2>ACOiwFRk^>1kc|LvSzXdK5Kz-Lb%Ih{YGCJuF?P%kD>2in!{>h?}{BKu^0 zt*NBAmPA{O*sN|>r^R=B>fT-~1wvii4@__o6iT7wp-(mKQyxkReTh+P4DCY5%$)nwgIwDqlr(%yP`P|5erXAH(DW6l0X0?0< z0gpX3-zq!HLk~3#(y8;BMx>J0?$$@nin%KpDg$N%q4 z&P=5Qp&9N%$B_`ZUZ8S28`X`VJ^1f4=wM*m{ebw>J#mQ!LP7j`B4J*#EH$$h@e9%u zsh*PyC@!OZz4#cB!tluPxO|tUbCXLiMg4T@ryq~Y3qo9`se3m)uB5^+FIn4WlJ~nw z?Rfb-ic41Z^S6BKze(>j^-C(x11K(8dSAzWz5hWwW7T_xrk7L?*M+zgBI$~>%}mcN zV!iNAcjS7C3wP5zcTxNL@}E9@@7Vay{`UKWKfN~n=^w12zgVn(dm`dQUd)NiTC{?PiK}Ij%FpzO-Vb;J;aCXV5 z`L?$(J6^83_JX-ww!>@fuNcL3(^zp_v+TTPqmoyxyO!a&j*sxHP{cEWlta@qr%sL= zs-#Ly@>)ZE9HH^qT|m0VmB3K-W)%vNux4LBEaY zQxW~mh`uYL-;U_JVfqIE000000CpMw?EliI`o+Je^*4I14&m3@@4w@x8t>{Cf0y10 z-*YdI{+Z}6_qW*z`x#w6C$B2Sr#(n<)j$nyKkZx?R^dFjN`IG!y7_E>WBji-;` zzqgBxM&nw~1U?m(wpOJ6L*GL*9|g413X}Nml(6k0jzhon`n}Dit>!&9?-Bq200000 z000009&d!ft{2Jgq~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mV?d00001 diff --git a/src/build.py b/src/build.py index ed0defc..7ed687b 100644 --- a/src/build.py +++ b/src/build.py @@ -17,7 +17,7 @@ def find_c_files(path: str): for entry in os.listdir(path): full_path = os.path.join(path, entry) if os.path.isdir(full_path): - list_files_recursive(full_path) + find_c_files(full_path) else: if full_path.endswith(".c"): paths.append(full_path) @@ -29,6 +29,9 @@ def build_mineral(args): if not os.path.isdir(args.folder_path): console.print("[b red]digpkg: failed to build mineral: specified folder doesn't exist![/]") sys.exit(1) + if os.path.isfile(os.path.join(args.folder_path, "main.so")): + console.print("[b red]digpkg: failed to build mineral: attempt to build compiled mineral![/]") + sys.exit(1) if not shutil.which("gcc"): console.print("[b red]digpkg: failed to build mineral: gcc was not found![/]") sys.exit(1) @@ -36,6 +39,11 @@ def build_mineral(args): # use gcc to compile the mineral with console.status("Compiling", spinner="bouncingBall", spinner_style="green") as status: c_files = find_c_files(args.folder_path) + + print(len(c_files)) + if len(c_files) == 0: + console.print("[b red]digpkg: failed to build mineral: no .c files found in the specified folder, are you sure you're compiling a mineral?[/]") + sys.exit(1) if subprocess.run([ "gcc", @@ -102,7 +110,10 @@ def build(args): f.write("# mylib\n") f.write("Introduce your module here!\n\nThis file will serve as an index page for all your docs.\n\n") f.write("## Subtitle (use this for categories)\n") - f.write("- [mylib_MyFunction](docs/my_function.md)") + f.write("- [mylib_MyFunction](docs/my_function.md)\n\n") + f.write("## Changelog\n") + f.write("### v0.0.1 (latest)\n") + f.write("- Initial release.\n") console.print("[:white_check_mark:] Generated a new package for you!") diff --git a/src/main.py b/src/main.py index 7c7f8c7..27f8090 100644 --- a/src/main.py +++ b/src/main.py @@ -29,7 +29,7 @@ def parse_arguments(): # publish command publish_command = sub_parsers.add_parser(name="publish", description="publish a package to the repository") - publish_command.add_argument("name", help="name and version of the package") + #publish_command.add_argument("name", help="name and version of the package") publish_command.add_argument("folder_path", help="path to the folder that will be uploaded") # remove command diff --git a/src/publish.py b/src/publish.py index 1683fd4..276b88d 100644 --- a/src/publish.py +++ b/src/publish.py @@ -1,3 +1,4 @@ +import configparser import tarfile import tempfile import os, sys @@ -13,14 +14,8 @@ console = Console() def publish(args): - if not "@" in args.name: - console.print(f"[b red]digpkg: failed to publish mineral: please include the version number in the package name. e.g: request@1.0.0") - sys.exit(1) - - split_name = args.name.split("@") - mineral_name = split_name[0] - version = split_name[1] - + mineral_name = os.path.basename(args.folder_path) + # sanity checks if not os.path.isdir(args.folder_path): console.print(f"[b red]digpkg: failed to publish mineral: \"{args.folder_path}\" is not a directory") @@ -31,6 +26,10 @@ def publish(args): if os.path.basename(os.path.normpath(args.folder_path)).endswith("_build"): console.print(f"\n[b yellow]You didn't remove the \"_build\" suffix from your mineral's folder name!\n\nIf this is intentional you can ignore this message, however it is bad practice.\nIf this is not intentional, you will be unable to install your package properly using dig.[/]") + config_parser = configparser.ConfigParser() + config_parser.read(os.path.join(args.folder_path, "mineral.ini")) + version = config_parser["package"]["version"] + # ask for user and pass console.print("[b]Please authenticate.\n[/]") try: diff --git a/stdlib/SUMMARY.md b/stdlib/SUMMARY.md new file mode 100644 index 0000000..d8f5cdc --- /dev/null +++ b/stdlib/SUMMARY.md @@ -0,0 +1,4 @@ +# stdlib +The standard library for Ground. + +This mineral has no functions because it is intended to just be a collection of minerals needed to do anything useful in Ground. diff --git a/stdlib/mineral.ini b/stdlib/mineral.ini new file mode 100644 index 0000000..9abce85 --- /dev/null +++ b/stdlib/mineral.ini @@ -0,0 +1,10 @@ +[package] +description = Standard library for Ground. +version = 1.2.0 +config_version = 1 + +[dependencies] +math=1.2.0 +request=1.2.0 +fileio=1.2.0 +