diff --git a/Cargo.toml b/Cargo.toml index accd96c5..923d719d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ categories = ["command-line-interface"] description = """ A simple to use, efficient, and full featured Command Line Argument Parser """ +edition = "2018" [badges] travis-ci = { repository = "clap-rs/clap" } diff --git a/src/build/arg/long.rs b/src/build/arg/key/long.rs similarity index 100% rename from src/build/arg/long.rs rename to src/build/arg/key/long.rs diff --git a/src/build/arg/key.rs b/src/build/arg/key/mod.rs similarity index 100% rename from src/build/arg/key.rs rename to src/build/arg/key/mod.rs diff --git a/src/build/arg/key/position.rs b/src/build/arg/key/position.rs new file mode 100644 index 00000000..15474daf --- /dev/null +++ b/src/build/arg/key/position.rs @@ -0,0 +1,13 @@ +pub struct Position(u64); + +impl Default for Position { + fn default() -> Self { + Position(1) + } +} + +impl Position { + fn new() -> Self { + Position(1) + } +} \ No newline at end of file diff --git a/src/build/arg/short.rs b/src/build/arg/key/short.rs similarity index 100% rename from src/build/arg/short.rs rename to src/build/arg/key/short.rs diff --git a/src/build/arg/position.rs b/src/build/arg/position.rs deleted file mode 100644 index e05c91b9..00000000 --- a/src/build/arg/position.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub struct Position { - index: u64 -} \ No newline at end of file diff --git a/src/build/arg/default_values.rs b/src/build/arg/value/default_values.rs similarity index 62% rename from src/build/arg/default_values.rs rename to src/build/arg/value/default_values.rs index c3aabfe6..aab161ca 100644 --- a/src/build/arg/default_values.rs +++ b/src/build/arg/value/default_values.rs @@ -1,13 +1,14 @@ -pub struct DefaultValue<'help> { - value: &'help str, +pub struct EnvDefaultValue<'help> { + key: &'help OsStr, + value: Option } - pub struct ConditionalDefault<'help> { - value: DefaultValue<'help>, + value: &'help str, other_arg: Option, other_value: Option<&'help str>, } pub struct DefaultValues<'help> { defaults: Vec>, + env: Option>, } \ No newline at end of file diff --git a/src/build/arg/delimiter.rs b/src/build/arg/value/delimiter.rs similarity index 100% rename from src/build/arg/delimiter.rs rename to src/build/arg/value/delimiter.rs diff --git a/src/build/arg/filter.rs b/src/build/arg/value/filter.rs similarity index 100% rename from src/build/arg/filter.rs rename to src/build/arg/value/filter.rs diff --git a/src/build/arg/value.rs b/src/build/arg/value/mod.rs similarity index 84% rename from src/build/arg/value.rs rename to src/build/arg/value/mod.rs index 603404d2..e7df2950 100644 --- a/src/build/arg/value.rs +++ b/src/build/arg/value/mod.rs @@ -1,6 +1,5 @@ pub struct Value<'help> { defaults: Option, - name: Option<&'help str>, filter: Filter, occurrence: Occurrence, requires_equals: bool, diff --git a/src/build/arg/possible_values.rs b/src/build/arg/value/possible_values.rs similarity index 100% rename from src/build/arg/possible_values.rs rename to src/build/arg/value/possible_values.rs diff --git a/src/build/arg/terminator.rs b/src/build/arg/value/terminator.rs similarity index 100% rename from src/build/arg/terminator.rs rename to src/build/arg/value/terminator.rs diff --git a/src/build/arg/value/value_name.rs b/src/build/arg/value/value_name.rs new file mode 100644 index 00000000..7e21581f --- /dev/null +++ b/src/build/arg/value/value_name.rs @@ -0,0 +1,15 @@ +use std::io; + +pub struct ValueName<'help>(&'help str); + +impl<'help> ValueName<'help> { + fn write_as_required(&self, w: W) -> io::Result { + write!(w, "<{}>", self.0) + } + fn write_as_optional(&self, w: W) -> io::Result { + write!(w, "[{}]", self.0) + } + fn write(&self, w: W) -> io::Result { + write!(w, "{}", self.0) + } +} \ No newline at end of file diff --git a/src/build/arg/value_name.rs b/src/build/arg/value_name.rs deleted file mode 100644 index cb2c0e1c..00000000 --- a/src/build/arg/value_name.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub struct ValueName<'help> { - name: &'help str, -} \ No newline at end of file