refacto declaration of option struct
@@ -45,12 +45,6 @@ fn run() -> Result<()> {
let matches = app::build_app().get_matches_from(env::args_os());
- let excluded: Vec<String> = if let Some(user_ignored) = matches.values_of("exclude") {
- user_ignored.map(String::from).collect()
- } else {
- Vec::new()
- };
-
if matches.is_present("languages") {
let iterator = Language::iter().filter(|x| *x != Language::Unknown);
@@ -60,14 +54,6 @@ fn run() -> Result<()> {
std::process::exit(0);
}
- let path = String::from(matches.value_of("input").unwrap());
-
- let ascii_language: Language = if let Some(ascii_language) = matches.value_of("ascii-language")
- {
- Language::from_str(&ascii_language.to_lowercase()).unwrap()
- } else {
- Language::Unknown
- };
let mut disabled_fields = InfoFieldOn {
..Default::default()
};
@@ -101,14 +87,6 @@ fn run() -> Result<()> {
}
}
- let ascii_colors: Vec<String> = if let Some(values) = matches.values_of("ascii-colors") {
- values.map(String::from).collect()
- } else {
- Vec::new()
- };
-
- let no_bold = !matches.is_present("no-bold");
-
let image = if let Some(image_path) = matches.value_of("image") {
Some(image::open(image_path).map_err(|_| Error::ImageLoadError)?)
} else {
@@ -136,28 +114,34 @@ fn run() -> Result<()> {
None
};
- let no_merges = matches.is_present("no-merge-commits");
-
- let no_color_blocks = matches.is_present("no-color-blocks");
-
- let number_of_authors: usize = if let Some(value) = matches.value_of("authors-number") {
- usize::from_str(value).unwrap()
- } else {
- 3
- };
-
let config = options::Options {
- path,
- ascii_language,
- ascii_colors,
+ path: String::from(matches.value_of("input").unwrap()),
+ ascii_language: if let Some(ascii_language) = matches.value_of("ascii-language") {
+ Language::from_str(&ascii_language.to_lowercase()).unwrap()
+ } else {
+ Language::Unknown
+ },
+ ascii_colors: if let Some(values) = matches.values_of("ascii-colors") {
+ values.map(String::from).collect()
+ } else {
+ Vec::new()
+ },
disabled_fields,
- no_bold,
- image,
+ no_bold: !matches.is_present("no-bold"),
+ image: image,
image_backend,
- no_merges,
- no_color_blocks,
- number_of_authors,
- excluded,
+ no_merges: matches.is_present("no-merge-commits"),
+ no_color_blocks: matches.is_present("no-color-blocks"),
+ number_of_authors: if let Some(value) = matches.value_of("authors-number") {
+ usize::from_str(value).unwrap()
+ } else {
+ 3
+ },
+ excluded: if let Some(user_ignored) = matches.values_of("exclude") {
+ user_ignored.map(String::from).collect()
+ } else {
+ Vec::new()
+ },
};
let info = Info::new(config)?;
