Skip to content

Commit

Permalink
switch for searching in description
Browse files Browse the repository at this point in the history
  • Loading branch information
pandalanax committed Feb 25, 2024
1 parent 3ec2000 commit 904d614
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ copy the output to clipboard (macOS):
hdfshelper -m core | pbcopy
```

search the description instead of the name (switch):
```bash
hdfshelper -s true
```

You can select more than one option to print with `<TAB>`.
![screenshot of fuzzyfind](images/hdfshelper.png?raw=true "Screenshot with added option with <TAB>")

Expand All @@ -34,11 +39,13 @@ Usage of hdfshelper:
- core [core-site.xml]
- yarn [yarn-site.xml]
- hdfs [hdfs-site.xml] (default "hdfs")
-s Wether to search in configuration names or descriptions(shorthand)
-switch
Wether to search in configuration names or descriptions
-v string
The version of hadoop in format: rx.y.z (e.g. r3.3.6)(shorthand) (default "current")
-version string
The version of hadoop in format: rx.y.z (e.g. r3.3.6) (default "current")
```
The version of hadoop in format: rx.y.z (e.g. r3.3.6) (default "current")```
## Building
```bash
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ type Configuration struct {
}

var (
mode string
version string
mode string
version string
fzf_desc bool
)

func getUrls(version string) map[string]string {
Expand All @@ -59,18 +60,21 @@ func main() {
- hdfs [hdfs-site.xml]`
defaultVersion = "current"
usageVersion = "The version of hadoop in format: rx.y.z (e.g. r3.3.6)"
defaultSwitch = false
usageSwitch = "Wether to search in configuration names or descriptions"
)
flag.StringVar(&mode, "mode", defaultMode, usageMode)
flag.StringVar(&mode, "m", defaultMode, usageMode+"(shorthand)")
flag.StringVar(&version, "version", defaultVersion, usageVersion)
flag.StringVar(&version, "v", defaultVersion, usageVersion+"(shorthand)")
flag.BoolVar(&fzf_desc, "switch", defaultSwitch, usageSwitch)
flag.BoolVar(&fzf_desc, "s", defaultSwitch, usageSwitch+"(shorthand)")

flag.Parse()

// fmt.Println(*mode)
modes := getUrls(version)
url, ok := modes[mode]
fmt.Println(modes)
if !ok {
log.Fatal("wrong mode. type --help for usage")
}
Expand All @@ -97,6 +101,9 @@ func main() {
idx, err := fuzzyfinder.FindMulti(
config.Property,
func(i int) string {
if fzf_desc {
return config.Property[i].Description
}
return config.Property[i].Name
},
fuzzyfinder.WithPreviewWindow(func(i, w, h int) string {
Expand Down

0 comments on commit 904d614

Please sign in to comment.