diff --git a/src/main/main.mbt b/src/main/main.mbt index 4b7c311..b08e8f6 100644 --- a/src/main/main.mbt +++ b/src/main/main.mbt @@ -1,5 +1,9 @@ // orbit: a package manager whose repository is any OCI registry. +///| +/// Orbit's version. A test keeps it equal to the one in moon.mod. +let orbit_version : String = "0.1.0" + ///| let usage : String = #|orbit - packages as OCI artifacts @@ -42,6 +46,7 @@ let usage : String = #| orbit env [-g] print the PATH line for your shell #| #|flags: -g, --global --manifest-path --locked --frozen + #| -h, --help -V, --version #|constraints: 1.2.3 =1.2.3 ==1.2.3 1.2.* ^1.2.0 ~1.2.0 >=1.2 <2.0 !=1.3.0 * #| (comma-separated clauses are ANDed, e.g. ">=1.2.0, <2.0.0") #|config: /config.toml @@ -189,6 +194,7 @@ async fn dispatch(args : Array[String]) -> Unit raise OrbitError { } match cmd { "help" | "-h" | "--help" => println(usage) + "-V" | "--version" => println("orbit \{orbit_version}") "new" => { if force_global { raise OrbitError("--global cannot be used with `orbit new`") diff --git a/src/main/registry_wbtest.mbt b/src/main/registry_wbtest.mbt index 2a256a5..fa0b80a 100644 --- a/src/main/registry_wbtest.mbt +++ b/src/main/registry_wbtest.mbt @@ -1077,3 +1077,11 @@ async test "large layers upload in chunks, or whole where that is unsupported" { } assert_true(other) } + +///| +async test "orbit --version matches moon.mod" { + // Tests may run from the module root or the package directory. + let path = if exists("moon.mod") { "moon.mod" } else { "../../moon.mod" } + let manifest = @fs.read_file(path).text() + assert_true(contains_str(manifest, "\nversion = \"\{orbit_version}\"\n")) +}