Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help command and modify README #46

Merged
merged 1 commit into from
Dec 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,14 +12,13 @@ You can drill down JSON interactively by using filtering queries like [jq](https

## Installation

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

### With homebrew taps (for Mac)
### With homebrew (for Mac)

```
brew tap simeji/jid
brew install jid
```

@@ -75,7 +74,7 @@ This json is used by [demo section](https://github.com/simeji/jid#demo).
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
```

#### With initial query
#### With a initial query

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

#### Load JSON from a file

```
jid < file.json
```

## Keymaps

|key|description|
|:-----------|:----------|
|`TAB` / `CTRL` + `I` |Show available items and choice them|
|`CTRL` + `W` |Delete from the cursor to the start of the word|
|`CTRL` + `F` / Right Arrow (:arrow_right:)|To the first character of the 'Filter'|
|`CTRL` + `B` / Left Arrow (:arrow_left:)|To the end of the 'Filter'|
|`CTRL` + `F` / Right Arrow (:arrow_right:)|Move cursor a character to the right|
|`CTRL` + `B` / Left Arrow (:arrow_left:)|Move cursor a character to the left|
|`CTRL` + `A`|To the first character of the 'Filter'|
|`CTRL` + `E`|To the end of the 'Filter'|
|`CTRL` + `J`|Scroll json buffer 1 line downwards|
47 changes: 47 additions & 0 deletions cmd/jid/jid.go
Original file line number Diff line number Diff line change
@@ -14,13 +14,21 @@ func main() {
content := os.Stdin

var qm bool
var help bool
var version bool
qs := "."

flag.BoolVar(&qm, "q", false, "Output query mode")
flag.BoolVar(&help, "h", false, "print a help")
flag.BoolVar(&help, "help", false, "print a help")
flag.BoolVar(&version, "version", false, "print the version and exit")
flag.Parse()

if help {
fmt.Println(getHelpString())
os.Exit(0)
}

if version {
fmt.Println(fmt.Sprintf("jid version v%s", VERSION))
os.Exit(0)
@@ -52,3 +60,42 @@ func run(e jid.EngineInterface, qm bool) int {
}
return 0
}

func getHelpString() string {
return `

============ Load JSON from a file ==============

$ jid < file.json

============ With a JSON filter mode =============

TAB / CTRL-I
Show available items and choice them

CTRL-W
Delete from the cursor to the start of the word

CTRL-F / Right Arrow
Move cursor a character to the right

CTRL-B / Left Arrow
Move cursor a character to the left

CTRL-A
To the first character of the 'Filter'

CTRL-E
To the end of the 'Filter'

CTRL-J
Scroll json buffer 1 line downwards

CTRL-K
Scroll json buffer 1 line upwards

CTRL-L
Change view mode whole json or keys (only object)

`
}