Skip to content

Commit

Permalink
feat(verbose): print the exit map
Browse files Browse the repository at this point in the history
  • Loading branch information
0x61nas committed Sep 26, 2023
1 parent b95dd03 commit 37ca987
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/clink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ impl Clink {
let mut finder = LinkFinder::new();
finder.kinds(&[LinkKind::Url]);

if config.verbose {
println!("Exit map: {exit_map:#?}")
}

Check warning on line 26 in src/clink.rs

View check run for this annotation

Codecov / codecov/patch

src/clink.rs#L24-L26

Added lines #L24 - L26 were not covered by tests
Clink {
config,
exit_map,
Expand Down Expand Up @@ -256,6 +260,7 @@ mod find_and_replace {
sleep_duration: 150,
params: HashSet::from(["foo".into()]),
exit: vec![],
verbose: false,
});
assert_eq!(
clink.find_and_replace("https://test.test/?foo=dsadsa",),
Expand Down
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub struct ClinkConfig {
pub sleep_duration: u64,
pub params: HashSet<Rc<str>>,
pub exit: Vec<Vec<Rc<str>>>,
#[serde(skip)]
pub verbose: bool,
}

impl ClinkConfig {
Expand All @@ -54,6 +56,7 @@ impl ClinkConfig {
sleep_duration: 150,
params: get_default_params(),
exit: get_default_exit(),
verbose: false,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ fn main() -> Result<(), confy::ConfyError> {

let config_path = PathBuf::from(args.config);

let cfg: ClinkConfig = load_config(&config_path);
let mut cfg: ClinkConfig = load_config(&config_path);
cfg.verbose = args.verbose;

if !config_path.is_file() {
confy::store_path(&config_path, &cfg)?;
Expand Down

0 comments on commit 37ca987

Please sign in to comment.