added repository list to onyx-pkg; bugfix in io.reader
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 30 Aug 2022 03:46:53 +0000 (22:46 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 30 Aug 2022 03:46:53 +0000 (22:46 -0500)
core/io/reader.onyx
scripts/onyx-pkg.onyx

index ab7fa0d1d964cf105baa05f37f5952199f430053..890b01383294db41057d0047733de7dca7d896ec 100644 (file)
@@ -90,7 +90,7 @@ read_all :: (use reader: ^Reader, allocator := context.allocator) -> [] u8 {
             break;
         }
 
-        if error != .None && error != .ReadPending {
+        if error != .None && error != .ReadPending && error != .EOF {
             reader_consume_error(reader);
             break;
         }
index c77e4d91f24305ea921f90be145e1a241025e497..e4420d1e37eeaf9ce481b0f6f6bcf37e3f211791 100644 (file)
@@ -1,8 +1,20 @@
 
 #load "core/std"
 
+//
+// A list of repository URLs to get packages from.
+// These should be formatted to have one formatted
+// argument, which the package name.
+Known_Repositories :: str.[
+    "{}",
+    "git://onyxlang.io/repo/{}"
+]
+
 Version :: SemVer.{0, 1, 1}
 
+
+
+
 use core
 
 global_arguments: struct {
@@ -131,6 +143,8 @@ run_add_command :: (args: [] cstr) {
     }
 
     dep     := string.as_str(args[0]);
+    dep      = Git.get_full_repo_uri(dep);
+
     version: SemVer;
     if args.count > 1 {
         if !conv.parse_any(^version, string.as_str(args[1])) {
@@ -624,6 +638,18 @@ Package :: struct {
 }
 
 Git :: struct {
+    get_full_repo_uri :: (repo: str) -> str {
+        for Known_Repositories {
+            r := tprintf(it, repo);
+            git_proc := os.process_spawn(git_path, .["ls-remote", "--tags", r]);
+            if os.process_wait(^git_proc) == .Success {
+                return r |> string.alloc_copy();
+            }
+        }
+
+        return "";
+    }
+
     get_available_versions :: (repo: str) -> [] SemVer {
         versions := make([..] SemVer);