Skip to content

Commit

Permalink
add --list, -l flag to list supported languages
Browse files Browse the repository at this point in the history
  • Loading branch information
vypxl committed Oct 22, 2019
1 parent 91b554c commit 2e0ac38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use colored::Color;

use crate::{Error, Result};

#[derive(PartialEq, Eq, Hash, Clone, EnumString)]
#[derive(PartialEq, Eq, Hash, Clone, EnumString, EnumIter)]
#[strum(serialize_all = "lowercase")]
pub enum Language {
Assembly,
Expand Down
17 changes: 17 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,24 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
"15".bright_white(),
)),
)
.arg(
Arg::with_name("list")
.short("l")
.long("list")
.help("Prints a list of all supported languages")
)
.get_matches();

if matches.is_present("list") {
let list = Language::iter()
.filter(|x| *x != Language::Unknown)
.map(|x| x.to_string().color(x.get_colors()[0]).to_string())
.collect::<Vec<String>>().join(", ");

print!("Supported languages:\n\n{}\n", list);
std::process::exit(0);
}

let dir = String::from(matches.value_of("directory").unwrap());
let custom_logo: Language =
Language::from_str(&matches.value_of("ascii_language").unwrap().to_lowercase())
Expand Down

0 comments on commit 2e0ac38

Please sign in to comment.