-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructuring to prepare for combine with extension branch
- Loading branch information
1 parent
48df01e
commit 6c5ddd4
Showing
9 changed files
with
87 additions
and
76 deletions.
There are no files selected for viewing
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
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,77 @@ | ||
use crate::fonts::font_handling::get_fonts; | ||
use clap::{Arg, ArgAction, ArgMatches, Command, ValueHint}; | ||
|
||
// █▄█ ██▀ █ █▀▄ ██▀ █▀▄ █▀ █ █ █▄ █ ▄▀▀ ▀█▀ █ ▄▀▄ █▄ █ ▄▀▀ | ||
// █ █ █▄▄ █▄▄ █▀ █▄▄ █▀▄ █▀ ▀▄█ █ ▀█ ▀▄▄ █ █ ▀▄▀ █ ▀█ ▄██ | ||
fn string_to_str(input: Vec<String>) -> Vec<&'static str> { | ||
let mut output: Vec<&'static str> = Vec::with_capacity(input.len()); | ||
for s in input { | ||
output.push(Box::leak(s.into_boxed_str())); | ||
} | ||
output | ||
} | ||
|
||
// █▀▄ ▄▀▄ █▀▄ ▄▀▀ ██▀ █ █▄ █ █▀▄ █ █ ▀█▀ | ||
// █▀ █▀█ █▀▄ ▄██ █▄▄ █ █ ▀█ █▀ ▀▄█ █ | ||
pub fn clap_parse() -> Command { | ||
let cmd = clap::Command::new("cargo") | ||
.bin_name("glyphrs") | ||
.before_help( | ||
"".to_owned() | ||
+ "-----------------------------\n" | ||
+ "▄▀ █ ▀▄▀ █▀▄ █▄█ █▀▄ ▄▀▀\n" | ||
+ "▀▄█ █▄▄ █ █▀ █ █ ▄ █▀▄ ▄██\n" | ||
+ "-----------------------------", | ||
) | ||
.about("A text art generator written in Rust") | ||
.arg( | ||
Arg::new("input") | ||
.required_unless_present("version") | ||
.help("the string to be converted") | ||
.value_hint(ValueHint::CommandString), | ||
) | ||
// ▄▀▄ █▀▄ ▄▀ ▄▀▀ | ||
// █▀█ █▀▄ ▀▄█ ▄██ | ||
.arg( | ||
Arg::new("font") | ||
.long("font") | ||
.short('f') | ||
.default_value("blocks_in_two_lines") | ||
.value_parser(string_to_str(get_fonts())) | ||
.help_heading("Output") | ||
.help("set the font") | ||
.value_hint(ValueHint::CommandString), | ||
) | ||
.arg( | ||
Arg::new("prefix") | ||
.long("prefix") | ||
.short('p') | ||
.default_value("") | ||
.help_heading("Output") | ||
.help("set the characters preceding each line, for example \"# \"") | ||
.value_hint(ValueHint::CommandString), | ||
) | ||
.arg( | ||
Arg::new("version") | ||
.long("version") | ||
.short('v') | ||
.action(ArgAction::SetTrue) | ||
.help("Print version information"), | ||
); | ||
|
||
cmd | ||
} | ||
|
||
// ▄▀▄ █▀▄ ▄▀ █▄█ ▄▀▄ █▄ █ █▀▄ █ █ █▄ █ ▄▀ | ||
// █▀█ █▀▄ ▀▄█ █ █ █▀█ █ ▀█ █▄▀ █▄▄ █ █ ▀█ ▀▄█ | ||
pub fn handle_args() -> ArgMatches { | ||
let matches: ArgMatches = clap_parse().get_matches(); | ||
|
||
let version: bool = *matches.get_one("version").unwrap(); | ||
if version { | ||
println!("glyphrs v{}", env!("CARGO_PKG_VERSION")); | ||
std::process::exit(0); | ||
} | ||
|
||
matches | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.