Compare commits

...

3 Commits

Author SHA1 Message Date
f6bfa6b8fd Merge branch 'main' of https://chookspace.com/ground/Digpkg 2026-01-23 16:39:42 +11:00
5bc61e30a6 fixed numerous bugs 2026-01-23 16:38:53 +11:00
e75da2f297 removed uneeded printing 2026-01-22 09:27:57 +11:00
11 changed files with 85 additions and 11 deletions

View File

@@ -17,7 +17,7 @@ def find_c_files(path: str):
for entry in os.listdir(path): for entry in os.listdir(path):
full_path = os.path.join(path, entry) full_path = os.path.join(path, entry)
if os.path.isdir(full_path): if os.path.isdir(full_path):
list_files_recursive(full_path) find_c_files(full_path)
else: else:
if full_path.endswith(".c"): if full_path.endswith(".c"):
paths.append(full_path) paths.append(full_path)
@@ -29,6 +29,9 @@ def build_mineral(args):
if not os.path.isdir(args.folder_path): if not os.path.isdir(args.folder_path):
console.print("[b red]digpkg: failed to build mineral: specified folder doesn't exist![/]") console.print("[b red]digpkg: failed to build mineral: specified folder doesn't exist![/]")
sys.exit(1) 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"): if not shutil.which("gcc"):
console.print("[b red]digpkg: failed to build mineral: gcc was not found![/]") console.print("[b red]digpkg: failed to build mineral: gcc was not found![/]")
sys.exit(1) sys.exit(1)
@@ -36,6 +39,11 @@ def build_mineral(args):
# use gcc to compile the mineral # use gcc to compile the mineral
with console.status("Compiling", spinner="bouncingBall", spinner_style="green") as status: with console.status("Compiling", spinner="bouncingBall", spinner_style="green") as status:
c_files = find_c_files(args.folder_path) 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([ if subprocess.run([
"gcc", "gcc",
@@ -102,7 +110,10 @@ def build(args):
f.write("# mylib\n") 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("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("## 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!") console.print("[:white_check_mark:] Generated a new package for you!")

View File

@@ -29,7 +29,7 @@ def parse_arguments():
# publish command # publish command
publish_command = sub_parsers.add_parser(name="publish", description="publish a package to the repository") 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") publish_command.add_argument("folder_path", help="path to the folder that will be uploaded")
# remove command # remove command

View File

@@ -1,3 +1,4 @@
import configparser
import tarfile import tarfile
import tempfile import tempfile
import os, sys import os, sys
@@ -13,14 +14,8 @@ console = Console()
def publish(args): def publish(args):
if not "@" in args.name: mineral_name = os.path.basename(args.folder_path)
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]
# sanity checks # sanity checks
if not os.path.isdir(args.folder_path): 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") 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"): 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.[/]") 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 # ask for user and pass
console.print("[b]Please authenticate.\n[/]") console.print("[b]Please authenticate.\n[/]")
try: try:

7
fileio/SUMMARY.md Normal file
View File

@@ -0,0 +1,7 @@
# fileio
Perform file system operations.
## Files
- [file_Read](docs/read.md)
- [file_Write](docs/write.md)

17
fileio/docs/read.md Normal file
View File

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

17
fileio/docs/write.md Normal file
View File

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

5
fileio/mineral.ini Normal file
View File

@@ -0,0 +1,5 @@
[package]
description=Provides file I/O support for Ground
version=1.2.0
[dependencies]

BIN
mineral.tar Normal file

Binary file not shown.

4
stdlib/SUMMARY.md Normal file
View File

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

10
stdlib/mineral.ini Normal file
View File

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

4
test.grnd Normal file
View File

@@ -0,0 +1,4 @@
extern "math"
call !math_RandomDouble 1.0 10.0 &dice
println $dice