feat(cli): print the release for --version (#169)
sigit --version and sigit -V print "sigit <version>" and exit 0. The flag was not recognized before, so siGit Code started a session and a script that asked for the version was left waiting on it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Seto Elkahfi committed
Oct 5, 2026 at 19:35 UTC
76920f7326862234f19d4c0e55f99db9dcb14d2d
3 files changed
+47
CHANGELOG.md
+9
@@ -1,5 +1,14 @@
1
# Changelog
2
3
+## Unreleased
4
+
5
+### Added
6
+
7
+- **`sigit --version` prints the release.** `sigit --version` and `sigit -V`
8
+ print `sigit <version>` on stdout and exit 0. Before, the flag was not
9
+ recognized and siGit Code started a session, which left a script that asked
10
+ for the version waiting.
11
+
12
## 1.6.1
13
14
### Added
src/main.rs
+6
@@ -4975,6 +4975,12 @@ async fn main() -> anyhow::Result<()> {
4975
// directly from a shell. These must be handled before the TTY/ACP split.
4976
if let Some(verb) = std::env::args().nth(1) {
4977
match verb.as_str() {
4978
+ // Printed before logging or any model setup, so a script can ask
4979
+ // which release it has without starting a session.
4980
+ "--version" | "-V" => {
4981
+ println!("sigit {}", env!("CARGO_PKG_VERSION"));
4982
+ return Ok(());
4983
+ }
4984
"login" => {
4985
init_logging(true);
4986
// `--password` keeps the old email/password prompt for anyone
tests/version_flag.rs
new
+32
@@ -0,0 +1,32 @@
1
+//! `sigit --version` answers and exits without starting a session.
2
+
3
+use std::process::{Command, Stdio};
4
+
5
+fn version_output(flag: &str) -> std::process::Output {
6
+ Command::new(env!("CARGO_BIN_EXE_sigit"))
7
+ .arg(flag)
8
+ // A closed stdin: a build that mistook the flag for a session would
9
+ // sit in ACP mode reading it.
10
+ .stdin(Stdio::null())
11
+ .output()
12
+ .expect("sigit runs")
13
+}
14
+
15
+#[test]
16
+fn version_flag_prints_the_release_and_exits() {
17
+ for flag in ["--version", "-V"] {
18
+ let output = version_output(flag);
19
+
20
+ assert!(output.status.success(), "{flag} exits 0");
21
+ assert_eq!(
22
+ String::from_utf8_lossy(&output.stdout),
23
+ format!("sigit {}\n", env!("CARGO_PKG_VERSION")),
24
+ "{flag} prints the release on stdout"
25
+ );
26
+ assert!(
27
+ output.stderr.is_empty(),
28
+ "{flag} logs nothing: {}",
29
+ String::from_utf8_lossy(&output.stderr)
30
+ );
31
+ }
32
+}