From 32714325a76cc33d1e04f9e451759f1f5057d108 Mon Sep 17 00:00:00 2001 From: nandithebull Date: Thu, 26 Nov 2026 18:30:49 -0800 Subject: [PATCH] Let orbit init run without a registry argument Co-Authored-By: Claude Sonnet 5.5 --- src/main/main.mbt | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/main.mbt b/src/main/main.mbt index 9f0b88a..99f8119 100644 --- a/src/main/main.mbt +++ b/src/main/main.mbt @@ -5,7 +5,7 @@ let usage : String = #|orbit - packages as OCI artifacts (via oras) #| #|usage: - #| orbit init [--plain-http] save a different default registry + #| orbit init [registry] [--plain-http] set up; optionally save a registry #| orbit publish [--no-latest] push /orbit.json + /files/ #| orbit install [@constraint]... install with dependencies #| orbit remove ... [--force] remove, then drop unused dependencies @@ -24,7 +24,12 @@ let usage : String = #|authentication: run `oras login ` once. ///| +/// With no registry, only create the directories: any saved config is left +/// alone and the built-in default is not written to disk. fn cmd_init(registry : String, plain_http : Bool) -> Unit raise OrbitError { + if registry == "" && plain_http { + raise OrbitError("usage: orbit init --plain-http") + } let root = orbit_root() sh_ok( "mkdir -p " + @@ -34,12 +39,14 @@ fn cmd_init(registry : String, plain_http : Bool) -> Unit raise OrbitError { " " + sq(root + "/tmp"), ) - write_text_atomic( - root + "/config.json", - config_to_text(Config::{ registry, plain_http, }), - ) + if registry != "" { + write_text_atomic( + root + "/config.json", + config_to_text(Config::{ registry, plain_http, }), + ) + } println("orbit root: \{root}") - println("registry: \{registry}") + println("registry: \{load_ctx().cfg.registry}") println("add to your shell profile:") println(" export PATH=\"\{root}/bin:$PATH\"") } @@ -70,8 +77,10 @@ fn dispatch(args : Array[String]) -> Unit raise OrbitError { match cmd { "help" | "-h" | "--help" => println(usage) "init" => { - need(pos, 1, "init [--plain-http]") - cmd_init(pos[0], flags.contains("--plain-http")) + cmd_init( + if pos.length() > 0 { pos[0] } else { "" }, + flags.contains("--plain-http"), + ) } "env" => println("export PATH=\"\{orbit_root()}/bin:$PATH\"") "publish" => {