-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix defaults in onlyargs_derive (#34)
- Fixes default for floats and integers. - Fixes struct fields named name (just don't name your field arg_name_ and you'll be ok). - Adds regression tests.
- Loading branch information
Showing
40 changed files
with
515 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#[test] | ||
fn compile_tests() { | ||
let t = trybuild::TestCases::new(); | ||
t.pass("compile_tests/default_bool_false.rs"); | ||
t.pass("compile_tests/default_bool_true.rs"); | ||
t.pass("compile_tests/default_f32.rs"); | ||
t.pass("compile_tests/default_f64.rs"); | ||
t.pass("compile_tests/default_i8.rs"); | ||
t.pass("compile_tests/default_i128.rs"); | ||
t.pass("compile_tests/default_isize.rs"); | ||
// TODO: Negatives are not supported yet! | ||
// t.pass("compile_tests/default_negative_i8.rs"); | ||
// t.pass("compile_tests/default_negative_i128.rs"); | ||
// t.pass("compile_tests/default_negative_isize.rs"); | ||
t.pass("compile_tests/default_osstring.rs"); | ||
t.pass("compile_tests/default_pathbuf.rs"); | ||
t.pass("compile_tests/default_string.rs"); | ||
t.pass("compile_tests/default_u8.rs"); | ||
t.pass("compile_tests/default_u128.rs"); | ||
t.pass("compile_tests/default_usize.rs"); | ||
|
||
t.pass("compile_tests/positional_f32.rs"); | ||
t.pass("compile_tests/positional_f64.rs"); | ||
t.pass("compile_tests/positional_i8.rs"); | ||
t.pass("compile_tests/positional_i128.rs"); | ||
t.pass("compile_tests/positional_isize.rs"); | ||
t.pass("compile_tests/positional_osstring.rs"); | ||
t.pass("compile_tests/positional_pathbuf.rs"); | ||
t.pass("compile_tests/positional_string.rs"); | ||
t.pass("compile_tests/positional_u8.rs"); | ||
t.pass("compile_tests/positional_usize.rs"); | ||
|
||
t.pass("compile_tests/empty.rs"); | ||
t.pass("compile_tests/optional.rs"); | ||
t.pass("compile_tests/struct_doc_comment.rs"); | ||
t.pass("compile_tests/struct_footer.rs"); | ||
|
||
t.compile_fail("compile_tests/conflicting_short_name.rs"); | ||
t.pass("compile_tests/manual_short_name.rs"); | ||
t.pass("compile_tests/ignore_short_name.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
min: i32, | ||
max: i32, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Only one short arg is allowed. `-m` also used on field `min` | ||
--> compile_tests/conflicting_short_name.rs:4:5 | ||
| | ||
4 | max: i32, | ||
| ^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(false)] | ||
maybe: bool, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(true)] | ||
maybe: bool, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42.123)] | ||
width: f32, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42.123)] | ||
width: f64, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42)] | ||
width: i128, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42)] | ||
width: i8, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42)] | ||
width: isize, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(-42)] | ||
width: i128, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(-42)] | ||
width: i8, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(-42)] | ||
width: isize, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default("foo bar")] | ||
name: std::ffi::OsString, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default("./foo/bar")] | ||
path: std::path::PathBuf, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default("foo bar")] | ||
name: String, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42)] | ||
width: u128, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42)] | ||
width: u8, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
#[default(42)] | ||
width: usize, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args {} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[derive(Debug, onlyargs_derive::OnlyArgs)] | ||
struct Args { | ||
min: i32, | ||
|
||
#[long] | ||
max: i32, | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.