Skip to content

Commit

Permalink
Merge pull request rust-lang#147 from passcod/cli-overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod authored May 31, 2022
2 parents 09129a4 + 2f9be15 commit f0e7fa0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ yes
21:15:30 [INFO] Installation complete!
```

### Unsupported crates

To install an unsupported crate, you may specify the Cargo.toml metadata entries for `pkg-url`, `bin-dir`, and `pkg-fmt` at the command line, with values [as documented below](#supporting-binary-installation).

For example:
```
$ binstall \
--pkg-url="{ repo }/releases/download/{ version }/{ name }-{ version }-{ target }.{ archive-format }" \
--pkg-fmt="txz" crate_name
```

## Status

Expand Down
20 changes: 19 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ struct Options {
/// Utility log level
#[structopt(long, default_value = "info")]
log_level: LevelFilter,

/// Override Cargo.toml package manifest bin-dir.
#[structopt(long)]
bin_dir: Option<String>,

/// Override Cargo.toml package manifest pkg-fmt.
#[structopt(long)]
pkg_fmt: Option<PkgFmt>,

/// Override Cargo.toml package manifest pkg-url.
#[structopt(long)]
pkg_url: Option<String>,
}

#[tokio::main]
Expand All @@ -73,7 +85,12 @@ async fn main() -> Result<(), anyhow::Error> {
}

// Load options
let opts = Options::from_iter(args.iter());
let mut opts = Options::from_iter(args.iter());
let cli_overrides = PkgOverride {
pkg_url: opts.pkg_url.take(),
pkg_fmt: opts.pkg_fmt.take(),
bin_dir: opts.bin_dir.take(),
};

// Setup logging
let mut log_config = ConfigBuilder::new();
Expand Down Expand Up @@ -133,6 +150,7 @@ async fn main() -> Result<(), anyhow::Error> {
meta.merge(&o);
}

meta.merge(&cli_overrides);
debug!("Found metadata: {:?}", meta);

// Compute install directory
Expand Down

0 comments on commit f0e7fa0

Please sign in to comment.