-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Run code formatter and enable clippy some clippy warns
- Loading branch information
Showing
4 changed files
with
41 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ version = "0.1.0" | |
edition = "2021" | ||
license = "MIT" | ||
keywords = ["lyrics", "cli", "rust"] | ||
categories = ["command-line-utilities"] | ||
readme = "README.md" | ||
authors = ["Ishan Joshi <[email protected]>"] | ||
description = "A simple CLI to get lyrics of a song from Genius using a public availed API" | ||
|
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 |
---|---|---|
@@ -1,53 +1,54 @@ | ||
use inquire::Text; | ||
|
||
pub fn get_input(msg: &str, help: Option<&str>, default: Option<&str>)->String{ | ||
let input = Text::new(msg) | ||
.with_help_message( | ||
help.unwrap_or(""), | ||
) | ||
.with_default( | ||
default.unwrap_or(""), | ||
) | ||
.prompt(); | ||
let input = input.unwrap(); | ||
input | ||
pub fn get_input(msg: &str, help: Option<&str>, default: Option<&str>) -> String { | ||
Text::new(msg) | ||
.with_help_message(help.unwrap_or("")) | ||
.with_default(default.unwrap_or("")) | ||
.prompt() | ||
.expect("Failed to get input") | ||
} | ||
|
||
pub fn parse_args() -> (String, String) { | ||
let args: Vec<String> = std::env::args().collect(); | ||
let mut input = String::new(); | ||
if args.len() > 1 { | ||
for i in 1..args.len() { | ||
input.push_str(&args[i]); | ||
input.push_str(" "); | ||
for arg in args.iter().skip(1) { | ||
input.push_str(arg); | ||
input.push(' '); | ||
} | ||
(input, args[1].clone()) | ||
} | ||
else{ | ||
let output = get_input("Get any song's lyrics: ".into(), "Enter the song name: ".into(), "Never Gonna Give You Up".into()); | ||
} else { | ||
let output = get_input( | ||
"Get any song's lyrics: ", | ||
"Enter the song name: ".into(), | ||
"Never Gonna Give You Up".into(), | ||
); | ||
(output, "lyrics".into()) | ||
} | ||
} | ||
|
||
pub fn print_help(){ | ||
bunt::println!("Please provide a song name, no need to put {$underline}quotes{/$} around it ;)"); | ||
pub fn print_help() { | ||
bunt::println!( | ||
"Please provide a song name, no need to put {$underline}quotes{/$} around it ;)" | ||
); | ||
bunt::println!("{$blue}{$underline}Usage:{/$}{/$} "); | ||
bunt::println!("lyrics {$yellow}<Song Name>{/$}"); | ||
bunt::println!("lyrics --help / -h"); | ||
bunt::println!("lyrics --version / -v"); | ||
} | ||
|
||
pub fn print_version(){ | ||
pub fn print_version() { | ||
bunt::println!("lyrics {$yellow}v0.1.0{/$}"); | ||
} | ||
|
||
pub fn splash_screen(){ | ||
bunt::println!("{$green} _ _ {/$}"); | ||
bunt::println!("{$red}| | (_) {/$}"); | ||
bunt::println!("{$blue}| | _ _ _ __ _ ___ ___ {/$}"); | ||
bunt::println!("{$yellow}| | | | | | '__| |/ __/ __|{/$}"); | ||
bunt::println!("{$yellow}| |___| |_| | | | | (__\\__ \\{/$}"); | ||
bunt::println!("{$blue}\\_____/\\__, |_| |_|\\___|___/{/$}"); | ||
bunt::println!("{$red} __/ | {/$}"); | ||
bunt::println!("{$green} |___/ {/$}Finder {$underline}v.0.1{/$}"); | ||
} | ||
#[allow(clippy::cognitive_complexity)] | ||
pub fn splash_screen() { | ||
bunt::println!("{$green} _ _ {/$}"); | ||
bunt::println!("{$red}| | (_) {/$}"); | ||
bunt::println!("{$blue}| | _ _ _ __ _ ___ ___ {/$}"); | ||
bunt::println!("{$yellow}| | | | | | '__| |/ __/ __|{/$}"); | ||
bunt::println!("{$yellow}| |___| |_| | | | | (__\\__ \\{/$}"); | ||
bunt::println!("{$blue}\\_____/\\__, |_| |_|\\___|___/{/$}"); | ||
bunt::println!("{$red} __/ | {/$}"); | ||
bunt::println!("{$green} |___/ {/$}Finder {$underline}v.0.1{/$}"); | ||
} |
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