Skip to content

Commit 08cc7b3

Browse files
authored
Merge pull request #46 from simeji/fix-help
Add help command and modify README
2 parents 97c7f90 + 02ea21e commit 08cc7b3

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ You can drill down JSON interactively by using filtering queries like [jq](https
1212

1313
## Installation
1414

15-
* [With homebrew taps (for Mac)](#with-homebrew-taps-for-mac)
15+
* [With homebrew (for Mac)](#with-homebrew-for-mac)
1616
* [Simply use "jid" command](#simply-use-jid-command)
1717
* [Build](#build)
1818

19-
### With homebrew taps (for Mac)
19+
### With homebrew (for Mac)
2020

2121
```
22-
brew tap simeji/jid
2322
brew install jid
2423
```
2524

@@ -75,7 +74,7 @@ This json is used by [demo section](https://github.com/simeji/jid#demo).
7574
echo '{"info":{"date":"2016-10-23","version":1.0},"users":[{"name":"simeji","uri":"https://github.com/simeji","id":1},{"name":"simeji2","uri":"https://example.com/simeji","id":2},{"name":"simeji3","uri":"https://example.com/simeji3","id":3}],"userCount":3}}'|jid
7675
```
7776

78-
#### With initial query
77+
#### With a initial query
7978

8079
First argument of `jid` is initial query.
8180
(Use JSON same as [Demo](#demo))
@@ -90,14 +89,20 @@ Sample for using [RDAP](https://datatracker.ietf.org/wg/weirds/documents/) data.
9089
curl -s http://rdg.afilias.info/rdap/domain/example.info | jid
9190
```
9291

92+
#### Load JSON from a file
93+
94+
```
95+
jid < file.json
96+
```
97+
9398
## Keymaps
9499

95100
|key|description|
96101
|:-----------|:----------|
97102
|`TAB` / `CTRL` + `I` |Show available items and choice them|
98103
|`CTRL` + `W` |Delete from the cursor to the start of the word|
99-
|`CTRL` + `F` / Right Arrow (:arrow_right:)|To the first character of the 'Filter'|
100-
|`CTRL` + `B` / Left Arrow (:arrow_left:)|To the end of the 'Filter'|
104+
|`CTRL` + `F` / Right Arrow (:arrow_right:)|Move cursor a character to the right|
105+
|`CTRL` + `B` / Left Arrow (:arrow_left:)|Move cursor a character to the left|
101106
|`CTRL` + `A`|To the first character of the 'Filter'|
102107
|`CTRL` + `E`|To the end of the 'Filter'|
103108
|`CTRL` + `J`|Scroll json buffer 1 line downwards|

cmd/jid/jid.go

+47
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ func main() {
1414
content := os.Stdin
1515

1616
var qm bool
17+
var help bool
1718
var version bool
1819
qs := "."
1920

2021
flag.BoolVar(&qm, "q", false, "Output query mode")
22+
flag.BoolVar(&help, "h", false, "print a help")
23+
flag.BoolVar(&help, "help", false, "print a help")
2124
flag.BoolVar(&version, "version", false, "print the version and exit")
2225
flag.Parse()
2326

27+
if help {
28+
fmt.Println(getHelpString())
29+
os.Exit(0)
30+
}
31+
2432
if version {
2533
fmt.Println(fmt.Sprintf("jid version v%s", VERSION))
2634
os.Exit(0)
@@ -52,3 +60,42 @@ func run(e jid.EngineInterface, qm bool) int {
5260
}
5361
return 0
5462
}
63+
64+
func getHelpString() string {
65+
return `
66+
67+
============ Load JSON from a file ==============
68+
69+
$ jid < file.json
70+
71+
============ With a JSON filter mode =============
72+
73+
TAB / CTRL-I
74+
Show available items and choice them
75+
76+
CTRL-W
77+
Delete from the cursor to the start of the word
78+
79+
CTRL-F / Right Arrow
80+
Move cursor a character to the right
81+
82+
CTRL-B / Left Arrow
83+
Move cursor a character to the left
84+
85+
CTRL-A
86+
To the first character of the 'Filter'
87+
88+
CTRL-E
89+
To the end of the 'Filter'
90+
91+
CTRL-J
92+
Scroll json buffer 1 line downwards
93+
94+
CTRL-K
95+
Scroll json buffer 1 line upwards
96+
97+
CTRL-L
98+
Change view mode whole json or keys (only object)
99+
100+
`
101+
}

0 commit comments

Comments
 (0)