mirror of
https://github.com/FliegendeWurst/tmux-thumbs.git
synced 2024-11-22 21:05:00 +00:00
Better handling of target param
This commit is contained in:
parent
7c739ce5c5
commit
e7d43e8ec2
@ -378,6 +378,7 @@ OPTIONS:
|
|||||||
-x, --regexp <regexp>... Use this regexp as extra pattern to match
|
-x, --regexp <regexp>... Use this regexp as extra pattern to match
|
||||||
--select-bg-color <select_background_color> Sets the background color for selection [default: black]
|
--select-bg-color <select_background_color> Sets the background color for selection [default: black]
|
||||||
--select-fg-color <select_foreground_color> Sets the foreground color for selection [default: blue]
|
--select-fg-color <select_foreground_color> Sets the foreground color for selection [default: blue]
|
||||||
|
-t, --target <target> Stores the hint in the specified path
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -109,8 +109,8 @@ fn app_args<'a>() -> clap::ArgMatches<'a> {
|
|||||||
Arg::with_name("target")
|
Arg::with_name("target")
|
||||||
.help("Stores the hint in the specified path")
|
.help("Stores the hint in the specified path")
|
||||||
.long("target")
|
.long("target")
|
||||||
.default_value("")
|
.short("t")
|
||||||
.short("t"),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
.get_matches()
|
.get_matches()
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ fn main() {
|
|||||||
let format = args.value_of("format").unwrap();
|
let format = args.value_of("format").unwrap();
|
||||||
let alphabet = args.value_of("alphabet").unwrap();
|
let alphabet = args.value_of("alphabet").unwrap();
|
||||||
let position = args.value_of("position").unwrap();
|
let position = args.value_of("position").unwrap();
|
||||||
let target = args.value_of("target").unwrap();
|
let target = args.value_of("target");
|
||||||
let multi = args.is_present("multi");
|
let multi = args.is_present("multi");
|
||||||
let reverse = args.is_present("reverse");
|
let reverse = args.is_present("reverse");
|
||||||
let unique = args.is_present("unique");
|
let unique = args.is_present("unique");
|
||||||
@ -182,9 +182,7 @@ fn main() {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
if target.is_empty() {
|
if let Some(target) = target {
|
||||||
print!("{}", output);
|
|
||||||
} else {
|
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.truncate(true)
|
.truncate(true)
|
||||||
@ -193,6 +191,8 @@ fn main() {
|
|||||||
.expect("Unable to open the target file");
|
.expect("Unable to open the target file");
|
||||||
|
|
||||||
file.write(output.as_bytes()).unwrap();
|
file.write(output.as_bytes()).unwrap();
|
||||||
|
} else {
|
||||||
|
print!("{}", output);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
::std::process::exit(1);
|
::std::process::exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user