Skip to content

Commit

Permalink
fix: Fix conflicts_with settings in config command
Browse files Browse the repository at this point in the history
Clap 4 requires the conflicting arg name to the Rust name, instead of
the user-visible arg name.
  • Loading branch information
theduke committed May 12, 2023
1 parent f21d370 commit cfbe94c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/cache/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Cache for FileSystemCache {
key.to_string()
};
let path = self.path.join(filename);
let ret = Module::deserialize_from_file(engine, path.clone());
let ret = Module::deserialize_from_file_checked(engine, path.clone());
if ret.is_err() {
// If an error occurs while deserializing then we can not trust it anymore
// so delete the cache file
Expand Down
12 changes: 6 additions & 6 deletions lib/cli-compiler/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ use std::path::PathBuf;
/// The options for the `wasmer config` subcommand
pub struct Config {
/// Print the installation prefix.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
prefix: bool,

/// Directory containing Wasmer executables.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
bindir: bool,

/// Directory containing Wasmer headers.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
includedir: bool,

/// Directory containing Wasmer libraries.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
libdir: bool,

/// Libraries needed to link against Wasmer components.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
libs: bool,

/// C compiler flags for files that include Wasmer headers.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
cflags: bool,

/// It outputs the necessary details for compiling
Expand Down
14 changes: 7 additions & 7 deletions lib/cli/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ pub struct Config {
#[derive(Debug, Parser)]
pub struct Flags {
/// Print the installation prefix.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
prefix: bool,

/// Directory containing Wasmer executables.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
bindir: bool,

/// Directory containing Wasmer headers.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
includedir: bool,

/// Directory containing Wasmer libraries.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
libdir: bool,

/// Libraries needed to link against Wasmer components.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
libs: bool,

/// C compiler flags for files that include Wasmer headers.
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
cflags: bool,

/// Print the path to the wasmer configuration file where all settings are stored
#[clap(long, conflicts_with = "pkg-config")]
#[clap(long, conflicts_with = "pkg_config")]
config_path: bool,

/// Outputs the necessary details for compiling
Expand Down
9 changes: 4 additions & 5 deletions tests/integration/cli/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@ fn wasmer_config_error() -> anyhow::Result<()> {
.map(|s| s.trim().to_string())
.collect::<Vec<_>>();
#[cfg(not(windows))]
let expected_1 = "wasmer config --bindir --cflags";
let expected_1 = "Usage: wasmer config --bindir --cflags";
#[cfg(windows)]
let expected_1 = "wasmer.exe config --bindir --cflags";
let expected_1 = "Usage: wasmer.exe config --bindir --cflags";

let expected = vec![
"error: The argument '--bindir' cannot be used with '--pkg-config'",
"error: the argument '--bindir' cannot be used with '--pkg-config'",
"",
"USAGE:",
expected_1,
"",
"For more information try --help",
"For more information, try '--help'.",
];

assert_eq!(lines, expected);
Expand Down

0 comments on commit cfbe94c

Please sign in to comment.