diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-10-07 19:45:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-07 19:45:49 +0200 |
commit | 30875d153f7320457f80e78830646d74f6f9f9e2 (patch) | |
tree | 4693b7377d6f8cf83f3391df03118158017e9335 /imag-ref | |
parent | 7611ad28929209b79b6c219f073705ed34901dfd (diff) | |
parent | d506e869ca62e740c6895d72decf70db719b634d (diff) |
Merge pull request #771 from matthiasbeyer/clap-validators
Clap validators
Diffstat (limited to 'imag-ref')
-rw-r--r-- | imag-ref/Cargo.toml | 3 | ||||
-rw-r--r-- | imag-ref/src/main.rs | 1 | ||||
-rw-r--r-- | imag-ref/src/ui.rs | 3 |
3 files changed, 7 insertions, 0 deletions
diff --git a/imag-ref/Cargo.toml b/imag-ref/Cargo.toml index da41fdcf..221615a2 100644 --- a/imag-ref/Cargo.toml +++ b/imag-ref/Cargo.toml @@ -27,3 +27,6 @@ path = "../libimaginteraction" [dependencies.libimagentrylist] path = "../libimagentrylist" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index 1d3a5a13..f7212b46 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -28,6 +28,7 @@ extern crate libimagref; extern crate libimagerror; extern crate libimagentrylist; extern crate libimaginteraction; +extern crate libimagutil; mod ui; use ui::build_ui; diff --git a/imag-ref/src/ui.rs b/imag-ref/src/ui.rs index 8fc952d0..5c4685e2 100644 --- a/imag-ref/src/ui.rs +++ b/imag-ref/src/ui.rs @@ -19,6 +19,8 @@ use clap::{Arg, App, SubCommand}; +use libimagutil::cli_validators::is_existing_path; + pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app .subcommand(SubCommand::with_name("add") @@ -30,6 +32,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .takes_value(true) .required(true) .help("The path of the file") + .validator(is_existing_path) .value_name("PATH")) .arg(Arg::with_name("track-content") .long("content-hash") |