Skip to content

Commit

Permalink
feat: use bright colors
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-rev committed Jan 2, 2025
1 parent 3397941 commit e113efb
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 46 deletions.
60 changes: 30 additions & 30 deletions src/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use crate::{
};

fn format_subcommand(command: &str, description: &str) -> String {
let command = command.yellow();
let command = command.bright_yellow();
format!("{command}\n {}", format_description(description))
}

pub fn format_description(description: &str) -> String {
format!("{} {description}", "»".black())
format!("{} {description}", "»".bright_black())
}

pub static HELP_FLAG: Flag<'static> = Flag {
Expand All @@ -38,13 +38,13 @@ pub static VERSION_FLAG: Flag<'static> = Flag {

pub fn help(command: Option<&str>) -> anyhow::Result<()> {
let author = "Nikita Revenco ".italic();
let less_than = "<".black().italic();
let less_than = "<".bright_black().italic();
let email = "[email protected]".italic();
let greater_than = ">".black().italic();
let app_name = APP_NAME.blue();
let flags_label = "[<flags>]".magenta();
let command_str = "<command>".yellow();
let args = "[<args>]".green();
let greater_than = ">".bright_black().italic();
let app_name = APP_NAME.bright_blue();
let flags_label = "[<flags>]".bright_magenta();
let command_str = "<command>".bright_yellow();
let args = "[<args>]".bright_green();
let version = env!("CARGO_PKG_VERSION");
let init = format_subcommand("init", "Create example config file");
let pr_fetch = format_subcommand(
Expand All @@ -62,7 +62,7 @@ pub fn help(command: Option<&str>) -> anyhow::Result<()> {

match command {
Some(cmd_name @ "init") => {
let this_command_name = format!("{app_name} {}", cmd_name.yellow());
let this_command_name = format!("{app_name} {}", cmd_name.bright_yellow());

let description = format_description("Create example config file");

Expand All @@ -82,7 +82,7 @@ pub fn help(command: Option<&str>) -> anyhow::Result<()> {
);
}
Some(cmd_name @ "run") => {
let this_command_name = format!("{app_name} {}", cmd_name.yellow());
let this_command_name = format!("{app_name} {}", cmd_name.bright_yellow());

let description = format_description("Create example config file");

Expand All @@ -102,7 +102,7 @@ pub fn help(command: Option<&str>) -> anyhow::Result<()> {
);
}
Some(cmd_name @ "gen-patch") => {
let this_command_name = format!("{app_name} {}", cmd_name.yellow());
let this_command_name = format!("{app_name} {}", cmd_name.bright_yellow());

let patch_filename_flag = format_flag(&GEN_PATCH_NAME_FLAG);

Expand All @@ -111,25 +111,25 @@ pub fn help(command: Option<&str>) -> anyhow::Result<()> {
let example_1 = format!(
"{}
{}",
"133cbaae83f710b793c98018cea697a04479bbe4".green(),
"133cbaae83f710b793c98018cea697a04479bbe4".bright_green(),
format_description("Generate a single .patch file from one commit hash")
);

let example_2 = format!(
"{}
{}",
"133cbaae83f710b793c98018cea697a04479bbe4 9ad5aa637ccf363b5d6713f66d0c2830736c35a9 cc75a895f344cf2fe83eaf6d78dfb7aeac8b33a4".green(),
"133cbaae83f710b793c98018cea697a04479bbe4 9ad5aa637ccf363b5d6713f66d0c2830736c35a9 cc75a895f344cf2fe83eaf6d78dfb7aeac8b33a4".bright_green(),
format_description("Generate several .patch files from several commit hashes")
);

let example_3 = format!(
"{} {} {} {} {}
{}",
"133cbaae83f710b793c98018cea697a04479bbe4".green(),
"--patch-filename=some-patch".magenta(),
"9ad5aa637ccf363b5d6713f66d0c2830736c35a9".green(),
"--patch-filename=another-patch".magenta(),
"cc75a895f344cf2fe83eaf6d78dfb7aeac8b33a4".green(),
"133cbaae83f710b793c98018cea697a04479bbe4".bright_green(),
"--patch-filename=some-patch".bright_magenta(),
"9ad5aa637ccf363b5d6713f66d0c2830736c35a9".bright_green(),
"--patch-filename=another-patch".bright_magenta(),
"cc75a895f344cf2fe83eaf6d78dfb7aeac8b33a4".bright_green(),
format_description(
"Generate several .patch files from several commit hashes and give 2 of them custom names"
)
Expand Down Expand Up @@ -166,25 +166,25 @@ pub fn help(command: Option<&str>) -> anyhow::Result<()> {
let example_1 = format!(
"{}
{}",
"11745".green(),
"11745".bright_green(),
format_description("Fetch a single pull request")
);

let example_2 = format!(
"{}
{}",
"11745 10000 9191 600".green(),
"11745 10000 9191 600".bright_green(),
format_description("Fetch several pull requests")
);

let example_3 = format!(
"{} {} {} {} {}
{}",
"11745 10000".green(),
"--branch-name=some-pr".magenta(),
"9191".green(),
"--branch-name=another-pr".magenta(),
"600".green(),
"11745 10000".bright_green(),
"--branch-name=some-pr".bright_magenta(),
"9191".bright_green(),
"--branch-name=another-pr".bright_magenta(),
"600".bright_green(),
format_description(
"Fetch several pull requests and choose custom branch names for the pull requests #10000 and #9191"
)
Expand All @@ -193,23 +193,23 @@ pub fn help(command: Option<&str>) -> anyhow::Result<()> {
let example_4 = format!(
"{} {} {}
{}",
"--repo-name=helix-editor/helix".magenta(),
"11745 10000 9191 600".green(),
"--checkout".magenta(),
"--repo-name=helix-editor/helix".bright_magenta(),
"11745 10000 9191 600".bright_green(),
"--checkout".bright_magenta(),
format_description("Fetch several pull requests, checkout the first one and use a custom github repo: https://github.com/helix-editor/helix")
);

let example_5 = format!(
"{}
{}",
"11745 10000@be8f264327f6ae729a0b372ef01f6fde49a78310 9191 600@5d10fa5beb917a0dbe0ef8441d14b3d0dd15227b".green(),
"11745 10000@be8f264327f6ae729a0b372ef01f6fde49a78310 9191 600@5d10fa5beb917a0dbe0ef8441d14b3d0dd15227b".bright_green(),
format_description("Fetch several pull requests at a certain commit")
);

let branch_name_flag = format_flag(&PR_FETCH_BRANCH_NAME_FLAG);
let checkout_flag = format_flag(&PR_FETCH_CHECKOUT_FLAG);
let repo_name_flag = format_flag(&PR_FETCH_REPO_NAME_FLAG);
let this_command_name = format!("{app_name} {}", cmd_name.yellow());
let this_command_name = format!("{app_name} {}", cmd_name.bright_yellow());

println!(
"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn init(_args: &CommandArgs) -> anyhow::Result<()> {
if config_file_path.exists()
&& !confirm_prompt!(
"File {} already exists. Overwrite it?",
config_file_path.to_string_lossy().blue(),
config_file_path.to_string_lossy().bright_blue(),
)
{
anyhow::bail!("Did not overwrite {config_file_path:?}");
Expand Down
4 changes: 2 additions & 2 deletions src/commands/pr_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ pub async fn pr_fetch(args: &CommandArgs) -> anyhow::Result<()> {
"{}{} {}",
"#".bright_blue(),
pull_request.bright_blue(),
response.title.blue().italic()
response.title.bright_blue().italic()
),
&response.html_url
),
info.branch.local_branch_name.cyan(),
info.branch.local_branch_name.bright_cyan(),
hash.clone()
.map(|commit_hash| format!(", at commit {}", commit_hash.bright_yellow()))
.unwrap_or_default()
Expand Down
12 changes: 6 additions & 6 deletions src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub async fn run(args: &CommandArgs) -> anyhow::Result<()> {

if confirm_prompt!(
"Would you like us to run {} {} to initialize it?",
"patchy".blue(),
"init".yellow(),
"patchy".bright_blue(),
"init".bright_yellow(),
) {
init(args)?;
}
Expand Down Expand Up @@ -134,7 +134,7 @@ pub async fn run(args: &CommandArgs) -> anyhow::Result<()> {
"{}{} {}",
"#".bright_blue(),
pull_request.bright_blue(),
&response.title.blue().italic()
&response.title.bright_blue().italic()
),
&response.html_url
),
Expand Down Expand Up @@ -194,7 +194,7 @@ pub async fn run(args: &CommandArgs) -> anyhow::Result<()> {
.lines()
.next()
.unwrap_or_default()
.blue()
.bright_blue()
.italic()
);
}
Expand Down Expand Up @@ -230,13 +230,13 @@ pub async fn run(args: &CommandArgs) -> anyhow::Result<()> {
&temporary_branch,
&config.local_branch,
])?;
println!("\n{INDENT}{}", " Success!\n".green().bold());
println!("\n{INDENT}{}", " Success!\n".bright_green().bold());
} else {
let command = format!(
" git branch --move --force {temporary_branch} {}",
config.local_branch
);
let command = format!("\n{INDENT}{}\n", command.magenta(),);
let command = format!("\n{INDENT}{}\n", command.bright_magenta(),);
println!(
"\n{INDENT} You can still manually overwrite {} with the following command:\n {command}",
config.local_branch.cyan(),
Expand Down
6 changes: 3 additions & 3 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ pub fn is_valid_flag(arg: &str, available_flags: &[&Flag]) -> bool {
pub fn format_flag(flag: &Flag) -> String {
format!(
"{}{}{}\n {}",
flag.short.magenta(),
", ".black(),
flag.long.magenta(),
flag.short.bright_magenta(),
", ".bright_black(),
flag.long.bright_magenta(),
format_description(flag.description)
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ async fn process_subcommand(subcommand: &str, args: CommandArgs) -> Result<()> {
" Unknown {unknown}: {}",
unrecognized,
unknown = if unrecognized.starts_with("-") {
"flag".red()
"flag".bright_red()
} else {
"command".red()
"command".bright_red()
}
)
.red()
.bright_red()
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ macro_rules! confirm_prompt {
Confirm::new()
.with_prompt(format!(
"\n{INDENT}{} {}",
"»".black(),
"»".bright_black(),
format!($($arg)*)
))
.interact()
Expand Down

0 comments on commit e113efb

Please sign in to comment.