Skip to content

Commit

Permalink
Add GITHUB_TOKEN help to subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Aug 14, 2024
1 parent e056b1d commit 2e622bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
anyhow = "^1"
clap = { version = "^4", features = ["derive", "env"] }
git2 = "^0"
lazy_static = "^1"
octocrab = "^0"
serde = "^1"
serde_yml = "^0"
Expand Down
25 changes: 12 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ use clap::builder::styling::Style;
use clap::{Parser, Subcommand};
use git2::Repository;
use images::ContainerImages;
use lazy_static::lazy_static;
use octocrab::commits::PullRequestTarget;
use octocrab::models::pulls;
use octocrab::models::pulls::ReviewState;
use octocrab::Octocrab;

const BOLD_UNDERLINE: Style = Style::new().bold().underline();
lazy_static! {
static ref GITHUB_TOKEN_HELP: String = format!(
"{BOLD_UNDERLINE}Environment variables:{BOLD_UNDERLINE:#}
GITHUB_TOKEN GitHub token to use for API requests
"
);
}

/// Program to simplify PCI double approval process across repositories
#[derive(Parser)]
#[command(version, about, long_about = None, after_help = format!("{BOLD_UNDERLINE}Environment variables:{BOLD_UNDERLINE:#}
GITHUB_TOKEN GitHub token to use for API requests
"))]
#[command(propagate_version = true)]
#[command(version, about, long_about = None, after_help = GITHUB_TOKEN_HELP.to_string(), propagate_version = true)]
// see https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/variables for environment variablesuse
struct Cli {
/// The git base ref to compare against
Expand Down Expand Up @@ -53,25 +58,19 @@ struct Cli {
}

#[derive(Subcommand)]
#[command(propagate_version = true)]
enum Commands {
/// Analyzes commits in a repo and finds relevant reviews
#[command(after_help = GITHUB_TOKEN_HELP.to_string())]
Repo {
/// GitHub git remote to use
remote: String,
},

/// Analyzes a helm-charts repo, finds sources from values.yaml files and runs repo subcommand on them
#[command(after_help = GITHUB_TOKEN_HELP.to_string())]
HelmChart {
/// Git repository where to discover images.yaml files
#[arg(
short,
long,
env = "GITHUB_WORKSPACE",
hide_env_values = true,
required = false,
global = true
)]
#[arg(env = "GITHUB_WORKSPACE", hide_env_values = true, required = false, global = true)]
workspace: String,
},
}
Expand Down

0 comments on commit 2e622bb

Please sign in to comment.