Let orbit init run without a registry argument
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
64fd782b0d
commit
32714325a7
1 file changed
+17
-8
+17
-8
@@ -5,7 +5,7 @@ let usage : String =
|
||||
#|orbit - packages as OCI artifacts (via oras)
|
||||
#|
|
||||
#|usage:
|
||||
#| orbit init <registry> [--plain-http] save a different default registry
|
||||
#| orbit init [registry] [--plain-http] set up; optionally save a registry
|
||||
#| orbit publish <dir> [--no-latest] push <dir>/orbit.json + <dir>/files/
|
||||
#| orbit install <name>[@constraint]... install with dependencies
|
||||
#| orbit remove <name>... [--force] remove, then drop unused dependencies
|
||||
@@ -24,7 +24,12 @@ let usage : String =
|
||||
#|authentication: run `oras login <registry-host>` 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 <registry> --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 <registry> [--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" => {
|
||||
|
||||
Reference in new issue
Block a user