Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

package: accept -o for --out (#1269)

jakalijey6a869e1cf19d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 93eec376..eb40193e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Unreleased
+- `package` takes `-o` for `--out`, as `analyze` and `bridge` do. Before, `package -o dir` was
+ refused as an unknown argument (#1249 by @jakalijey).
- PHP, Swift and C: when a unit has functions that stay in the original language (a variadic one,
one with a pointer parameter, one named with `--keep`), the cut-over advice names them and says
to move them out of the original file first: in the crate's README and the wrapper's header for
diff --git a/src/main.rs b/src/main.rs
index db06287e..9a7b5dab 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -513,7 +513,7 @@ enum Cmd {
#[arg(long)]
version: Option<String>,
/// Output folder; defaults to `<crate>/package`.
- #[arg(long, value_parser = absolute)]
+ #[arg(long, short, value_parser = absolute)]
out: Option<PathBuf>,
/// napi: the module to load where no binary fits (defaults to the original file when it
/// imports nothing).
diff --git a/tests/package.rs b/tests/package.rs
index 9245ebba..ac082a71 100644
--- a/tests/package.rs
+++ b/tests/package.rs
@@ -343,6 +343,26 @@ fn package_dry_run_names_what_it_counts() {
rest[expected_word.len()..].starts_with(" for [email protected] in "),
"{first}"
);
+
+ // -o is --out, as for analyze, bridge, report and shadow.
+ let short_out = root.join("short-out");
+ let out = common::cli()
+ .args(["package", "--dry-run", "-o"])
+ .arg(&short_out)
+ .arg(&dir)
+ .output()
+ .unwrap();
+ assert!(
+ out.status.success(),
+ "{}",
+ String::from_utf8_lossy(&out.stderr)
+ );
+ let stdout = String::from_utf8_lossy(&out.stdout);
+ let first = stdout.lines().next().unwrap_or("");
+ assert!(
+ first.ends_with(&format!(" in {}:", short_out.display())),
+ "{first}"
+ );
std::fs::remove_dir_all(root).unwrap();
}
diff --git a/website/content/cli-help.json b/website/content/cli-help.json
index 0924e289..e3ddf6f2 100644
--- a/website/content/cli-help.json
+++ b/website/content/cli-help.json
@@ -75,7 +75,7 @@
},
{
"command": "package",
- "help": "6. Lay out installable packages and a CI workflow for every platform; never publishes\n\nUsage: rust-anything package [OPTIONS] [CRATE_DIR]\n\nArguments:\n [CRATE_DIR] Crate folder made by `bridge` [default: .]\n\nOptions:\n --name <NAME> Package name on npm or PyPI; defaults to the crate name\n --version <VERSION> Package version; defaults to the original package's\n --out <OUT> Output folder; defaults to `<crate>/package`\n --fallback <FALLBACK> napi: the module to load where no binary fits (defaults to the original file when it imports nothing)\n --bin <BIN> CLI front door: a command the package installs (repeat for more); defaults to the package name without its scope\n --original <ORIGINAL> CLI front door: the original npm package it falls back to, as <name>@<version>; defaults to the one in the repository's node_modules\n --dry-run List the files, write nothing\n --json Print the machine-readable report as JSON\n -h, --help Print help\n"
+ "help": "6. Lay out installable packages and a CI workflow for every platform; never publishes\n\nUsage: rust-anything package [OPTIONS] [CRATE_DIR]\n\nArguments:\n [CRATE_DIR] Crate folder made by `bridge` [default: .]\n\nOptions:\n --name <NAME> Package name on npm or PyPI; defaults to the crate name\n --version <VERSION> Package version; defaults to the original package's\n -o, --out <OUT> Output folder; defaults to `<crate>/package`\n --fallback <FALLBACK> napi: the module to load where no binary fits (defaults to the original file when it imports nothing)\n --bin <BIN> CLI front door: a command the package installs (repeat for more); defaults to the package name without its scope\n --original <ORIGINAL> CLI front door: the original npm package it falls back to, as <name>@<version>; defaults to the one in the repository's node_modules\n --dry-run List the files, write nothing\n --json Print the machine-readable report as JSON\n -h, --help Print help\n"
},
{
"command": "app",