Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ User-visible and operationally material changes. Release notes with every commit

## [Unreleased]

## [0.4.0] - 2026-11-24
### Added
- `migadu --version` (and `-V`) prints the version.

## [0.3.4] - 2026-11-24
### Added
- Demo GIF in the README, with its recording script in `docs/demo.tape`.
Expand Down Expand Up @@ -37,7 +41,8 @@ First published release (Node.js; versions before it were never tagged).
- `migadu catchall`, `migadu spam` and `migadu bcc`, driven through the admin panel's forms.
- Releases are tagged, built and published automatically when the version changes on `main`.

[Unreleased]: https://github.com/ifthenelse/migadu-cli/compare/v0.3.4...HEAD
[Unreleased]: https://github.com/ifthenelse/migadu-cli/compare/v0.4.0...HEAD
[0.4.0]: https://github.com/ifthenelse/migadu-cli/compare/v0.3.4...v0.4.0
[0.3.4]: https://github.com/ifthenelse/migadu-cli/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/ifthenelse/migadu-cli/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/ifthenelse/migadu-cli/compare/v0.3.1...v0.3.2
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "migadu-cli"
version = "0.3.4"
version = "0.4.0"
edition = "2021"
rust-version = "1.85"
description = "Cross-platform CLI for the Migadu email hosting API, with password-manager credential lookup."
Expand Down
1 change: 1 addition & 0 deletions docs/specifications/functional-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Errors are one line on stderr, `error: <message>`. Output on stdout is JSON by d
| `-y, --yes` | Confirms a delete or a clearing action. Without it the command refuses. |
| `-o, --output json\|table` | Output format. `table` shows up to six scalar columns. |
| `-h, --help` | Print usage. |
| `-V, --version` | Print `migadu <version>` and exit; needs no credentials. |

## Configuration
| Variable | Required | Meaning |
Expand Down
19 changes: 12 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Options:
-y, --yes confirm delete
-o, --output json|table output format (default json)
-h, --help
-V, --version

Plan lookup reads the admin panel with a session cookie: MIGADU_WEB_COOKIE or MIGADU_WEB_COOKIE_REF.
Credentials: MIGADU_EMAIL plus MIGADU_API_KEY or MIGADU_API_KEY_REF
Expand All @@ -51,6 +52,7 @@ struct Opts {
yes: bool,
output: String,
help: bool,
version: bool,
pos: Vec<String>,
}

Expand Down Expand Up @@ -90,13 +92,11 @@ fn parse_args(args: &[String]) -> std::result::Result<Opts, String> {
"field" => o.field.push(take(&mut i, "-f, --field", inline)?),
"json" => o.json = Some(take(&mut i, "--json", inline)?),
"output" => o.output = take(&mut i, "-o, --output", inline)?,
"yes" | "help" if inline.is_none() => {
if name == "yes" {
o.yes = true
} else {
o.help = true
}
}
"yes" | "help" | "version" if inline.is_none() => match name {
"yes" => o.yes = true,
"help" => o.help = true,
_ => o.version = true,
},
_ => return Err(format!("Unknown option '--{name}'")),
}
} else {
Expand All @@ -109,6 +109,7 @@ fn parse_args(args: &[String]) -> std::result::Result<Opts, String> {
match c {
'y' => o.yes = true,
'h' => o.help = true,
'V' => o.version = true,
'd' | 'f' | 'o' => {
let v = take(&mut i, &format!("-{c}"), inline)?;
match c {
Expand Down Expand Up @@ -360,6 +361,10 @@ pub fn run(
return 2;
}
};
if o.version {
(io.out)(&format!("migadu {}", env!("CARGO_PKG_VERSION")));
return 0;
}
let res = o.pos.first().cloned();
if o.help || res.is_none() {
(io.out)(HELP.trim_end_matches('\n'));
Expand Down
23 changes: 23 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ fn bad_options_exit_with_code_2() {
assert!(help.out[0].starts_with("migadu — Migadu email hosting"));
}

#[test]
fn version_flag_prints_the_crate_version_and_needs_no_credentials() {
let want = format!("migadu {}", env!("CARGO_PKG_VERSION"));
for flag in ["--version", "-V"] {
let r = run_cli(&[flag], &env(&[]), &ok_empty(), &FakeExec::new());
assert_eq!(
(r.code, r.out.as_slice()),
(0, &[want.clone()][..]),
"{flag}"
);
}
assert_eq!(
run_cli(
&["domains", "list", "-V"],
&env(&[]),
&ok_empty(),
&FakeExec::new()
)
.out,
[want]
);
}

#[test]
fn table_output_lists_scalar_columns() {
let h = Fake::new(|_| {
Expand Down
Loading