forked from sirwart/ripsecrets
-
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.
Generate manpage as part of build (sirwart#83)
* Generate manpage via `clap_mangen` * Cleanup CLI docstrings
- Loading branch information
1 parent
6b3d1aa
commit 07e705b
Showing
5 changed files
with
84 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
include!("src/args.rs"); | ||
|
||
fn main() -> std::io::Result<()> { | ||
// Tell Cargo that if the given file changes, to rerun this build script. | ||
println!("cargo:rerun-if-changed=src/args.rs"); | ||
|
||
let out_dir = | ||
std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?); | ||
|
||
let cmd = <Args as clap::CommandFactory>::command(); | ||
|
||
let man = clap_mangen::Man::new(cmd); | ||
let mut buffer: Vec<u8> = Default::default(); | ||
man.render(&mut buffer)?; | ||
|
||
println!("{:?}", buffer); | ||
|
||
std::fs::write(out_dir.join("ripsecrets.1"), buffer)?; | ||
|
||
Ok(()) | ||
} |
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,41 @@ | ||
use clap::Parser; | ||
use std::path::PathBuf; | ||
|
||
/// Prevent committing secret keys into your source code. | ||
#[derive(Parser, Debug)] | ||
#[clap( | ||
version, | ||
about, | ||
name = "ripsecrets", | ||
long_about = "ripsecrets searches files and directories recursively for secret API keys. | ||
It's primarily designed to be used as a pre-commit to prevent committing | ||
secrets into version control." | ||
)] | ||
struct Args { | ||
/// Install `ripsecrets` as a pre-commit hook automatically in git directory provided. | ||
#[clap(long = "install-pre-commit")] | ||
install_pre_commit: bool, | ||
|
||
/// If you pass a path as an argument that's ignored by .secretsignore it | ||
/// will be scanned by default. --strict-ignore will override this | ||
/// behavior and not search the paths passed as arguments that are excluded | ||
/// by the .secretsignore file. This is useful when invoking secrets as a | ||
/// pre-commit. | ||
#[clap(long = "strict-ignore")] | ||
strict_ignore: bool, | ||
|
||
/// Print only the matched (non-empty) parts of a matching line, with each such | ||
/// part on a separate output line. | ||
#[clap(long = "only-matching")] | ||
only_matching: bool, | ||
|
||
/// Additional regex patterns used to find secrets. If there is a matching | ||
/// group in the regex the matched group will be tested for randomness before | ||
/// being reported as a secret. | ||
#[clap(long = "additional-pattern")] | ||
additional_patterns: Vec<String>, | ||
|
||
/// Source files. Can be files or directories. Defaults to '.' | ||
#[clap(name = "Source files")] | ||
paths: Vec<PathBuf>, | ||
} |
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