Skip to content

Commit f0199d6

Browse files
authored
Merge pull request #207 from Alexendoo/validators
Remove host and script validators
2 parents 4cf934f + 46f77b2 commit f0199d6

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

src/main.rs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ struct Opts {
9595
#[clap(
9696
long,
9797
help = "Host triple for the compiler",
98-
default_value_t = option_env!("HOST").unwrap_or("unkown").to_string(),
99-
validator = validate_host
100-
)]
98+
default_value = env!("HOST"),
99+
)]
101100
host: String,
102101

103102
#[clap(long, help = "Cross-compilation target platform")]
@@ -177,8 +176,7 @@ a date (YYYY-MM-DD), git tag name (e.g. 1.58.0) or git commit SHA."
177176
#[clap(
178177
long,
179178
help = "Script replacement for `cargo build` command",
180-
parse(from_os_str),
181-
validator = validate_file,
179+
parse(from_os_str)
182180
)]
183181
script: Option<PathBuf>,
184182

@@ -200,25 +198,6 @@ fn validate_dir(s: &str) -> anyhow::Result<()> {
200198
}
201199
}
202200

203-
fn validate_file(s: &str) -> anyhow::Result<()> {
204-
let path: PathBuf = s.parse()?;
205-
if path.is_file() {
206-
Ok(())
207-
} else {
208-
bail!("{} is not an existing file", path.canonicalize()?.display())
209-
}
210-
}
211-
212-
fn validate_host(s: &str) -> anyhow::Result<()> {
213-
if s == "unknown" {
214-
bail!(
215-
"Failed to auto-detect host triple and was not specified. Please provide it via --host"
216-
)
217-
} else {
218-
Ok(())
219-
}
220-
}
221-
222201
#[derive(Clone, Debug)]
223202
enum Bound {
224203
Commit(String),
@@ -1289,16 +1268,4 @@ mod tests {
12891268
validate_dir(main).unwrap_err()
12901269
)
12911270
}
1292-
1293-
#[test]
1294-
fn test_validate_file() {
1295-
let current_dir = ".";
1296-
assert!(validate_file(current_dir).is_err());
1297-
let main = "src/main.rs";
1298-
assert!(
1299-
validate_file(main).is_ok(),
1300-
"{}",
1301-
validate_dir(main).unwrap_err()
1302-
)
1303-
}
13041271
}

0 commit comments

Comments
 (0)