Skip to content

Commit cb2cc44

Browse files
committed
wip
1 parent 578f21d commit cb2cc44

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ jobs:
197197

198198
- name: --chdir
199199
run: |
200+
set -x
200201
d=$(mktemp -d)
201202
test $(pwd) != $d
202203
test $(pkgx -C $d -- pwd) = $d

crates/cli/src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2929
}
3030

3131
if flags.version_n_continue {
32-
eprintln!("pkgx {}", env!("CARGO_PKG_VERSION"));
32+
print_version(flags.json.is_some());
3333
}
3434

3535
match mode {
@@ -38,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3838
Ok(())
3939
}
4040
args::Mode::Version => {
41-
println!("pkgx {}", env!("CARGO_PKG_VERSION"));
41+
print_version(flags.json.is_some());
4242
Ok(())
4343
}
4444
args::Mode::Query => {
@@ -100,3 +100,14 @@ async fn setup(
100100

101101
Ok((conn, did_sync, config, spinner))
102102
}
103+
104+
fn print_version(json: bool) {
105+
if !json {
106+
eprintln!("pkgx {}", env!("CARGO_PKG_VERSION"));
107+
} else {
108+
eprintln!(
109+
"{{\"program\": \"pkgx\", \"version\": \"{}\"}}",
110+
env!("CARGO_PKG_VERSION")
111+
);
112+
}
113+
}

0 commit comments

Comments
 (0)