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

v0.5.0: Async has arrived in jnv #67

Merged
merged 19 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
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
286 changes: 268 additions & 18 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jnv"
version = "0.4.2"
version = "0.5.0"
authors = ["ynqa <un.pensiero.vano@gmail.com>"]
edition = "2021"
description = "JSON navigator and interactive filter leveraging jq"
Expand All @@ -9,15 +9,21 @@ license = "MIT"
readme = "README.md"

[dependencies]
anyhow = "1.0.82"
clap = { version = "4.5.4", features = ["derive"] }
arboard = "3.4.0"
anyhow = "1.0.95"
arboard = "3.4.1"
async-trait = "0.1.83"
clap = { version = "4.5.23", features = ["derive"] }
# See https://github.com/crossterm-rs/crossterm/issues/935
crossterm = { version = "0.28.1", features = ["use-dev-tty", "event-stream", "libc"] }
futures = "0.3.30"
futures-timer = "3.0.3"
jaq-core = "1.2.1"
jaq-interpret = "1.2.1"
jaq-parse = "1.0.2"
jaq-std = "1.2.1"
promkit = "0.6.0"
radix_trie = "0.2.1"
promkit = "0.6.2"
tokio = { version = "1.42.0", features = ["full"] }
tokio-stream = "0.1.16"

# The profile that 'cargo dist' will build with
[profile.dist]
Expand Down
90 changes: 50 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,34 +123,53 @@ jnv data.json

## Keymap

| Key | Action
| :- | :-
| <kbd>Ctrl + C</kbd> | Exit `jnv`
| <kbd>Tab</kbd> | jq filter auto-completion
| <kbd>←</kbd> | Move the cursor one character to the left
| <kbd>→</kbd> | Move the cursor one character to the right
| <kbd>Ctrl + A</kbd> | Move the cursor to the start of the filter
| <kbd>Ctrl + E</kbd> | Move the cursor to the end of the filter
| <kbd>Backspace</kbd> | Delete a character of filter at the cursor position
| <kbd>Ctrl + U</kbd> | Delete all characters of filter
| <kbd>↑</kbd>, <kbd>Ctrl + K</kbd> | Move the cursor one entry up in JSON viewer
| <kbd>↓</kbd>, <kbd>Ctrl + J</kbd> | Move the cursor one entry down in JSON viewer
| <kbd>Ctrl + H</kbd> | Move to the last entry in JSON viewer
| <kbd>Ctrl + L</kbd> | Move to the first entry in JSON viewer
| <kbd>Enter</kbd> | Toggle expand/collapse in JSON viewer
| <kbd>Ctrl + P</kbd> | Expand all folds in JSON viewer
| <kbd>Ctrl + N</kbd> | Collapse all folds in JSON viewer
| <kbd>Alt + B</kbd> | Move the cursor to the previous nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`)
| <kbd>Alt + F</kbd> | Move the cursor to the next nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`)
| <kbd>Ctrl + W</kbd> | Erase to the previous nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`)
| <kbd>Alt + D</kbd> | Erase to the next nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`)
| <kbd>Ctrl + O</kbd> | Copy current JSON content to clipboard
| <kbd>Ctrl + Q</kbd> | Copy current query to clipboard
| Key | Action |
| :- | :- |
| <kbd>Ctrl + C</kbd> | Exit |
| <kbd>Ctrl + Q</kbd> | Copy jq filter to clipboard |
| <kbd>Ctrl + O</kbd> | Copy JSON to clipboard |
| <kbd>Shift + ↑</kbd>, <kbd>Shift + ↓</kbd> | Switch to another mode |

### Editor mode (default)

| Key | Action |
| :- | :- |
| <kbd>Tab</kbd> | Enter suggestion |
| <kbd>←</kbd> | Move cursor left |
| <kbd>→</kbd> | Move cursor right |
| <kbd>Ctrl + A</kbd> | Move cursor to line start |
| <kbd>Ctrl + E</kbd> | Move cursor to line end |
| <kbd>Backspace</kbd> | Delete character before cursor |
| <kbd>Ctrl + U</kbd> | Clear entire line |
| <kbd>Alt + B</kbd> | Move the cursor to the previous nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`) |
| <kbd>Alt + F</kbd> | Move the cursor to the next nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`) |
| <kbd>Ctrl + W</kbd> | Erase to the previous nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`) |
| <kbd>Alt + D</kbd> | Erase to the next nearest character within set(`.`,`\|`,`(`,`)`,`[`,`]`) |

#### Suggestion in Editor (after <kbd>Tab</kbd>)

| Key | Action |
| :- | :- |
| <kbd>Tab</kbd>, <kbd>↓</kbd> | Select next suggestion |
| <kbd>↑</kbd> | Select previous suggestion |
| Others | Return to editor |

### JSON viewer mode

| Key | Action |
| :- | :- |
| <kbd>↑</kbd>, <kbd>Ctrl + K</kbd> | Move up |
| <kbd>↓</kbd>, <kbd>Ctrl + J</kbd> | Move down |
| <kbd>Ctrl + H</kbd> | Move to last entry |
| <kbd>Ctrl + L</kbd> | Move to first entry |
| <kbd>Enter</kbd> | Toggle fold |
| <kbd>Ctrl + P</kbd> | Expand all |
| <kbd>Ctrl + N</kbd> | Collapse all |

## Usage

```bash
JSON navigator and interactive filter leveraging jq
SON navigator and interactive filter leveraging jq

Usage: jnv [OPTIONS] [INPUT]

Expand All @@ -165,22 +184,13 @@ Arguments:
[INPUT] Optional path to a JSON file. If not provided or if "-" is specified, reads from standard input

Options:
-e, --edit-mode <EDIT_MODE>
Edit mode for the interface ('insert' or 'overwrite'). [default: insert]
-i, --indent <INDENT>
Number of spaces used for indentation in the visualized data. [default: 2]
-n, --no-hint
Disables the display of hints.
-d, --expand-depth <JSON_EXPAND_DEPTH>
Initial depth to which JSON nodes are expanded in the visualization. [default: 3]
-s, --limit-length <JSON_LIMIT_LENGTH>
Limit length of JSON array in the visualization. [default: 50]
-l, --suggestion-list-length <SUGGESTION_LIST_LENGTH>
Number of suggestions visible in the list. [default: 3]
-h, --help
Print help (see more with '--help')
-V, --version
Print version
-e, --edit-mode <EDIT_MODE> Edit mode for the interface ('insert' or 'overwrite'). [default: insert]
-i, --indent <INDENT> Number of spaces used for indentation in the visualized data. [default: 2]
-n, --no-hint Disables the display of hints.
--max-streams <MAX_STREAMS> Maximum number of JSON streams to display
--suggestions <SUGGESTIONS> Number of autocomplete suggestions to show [default: 3]
-h, --help Print help (see more with '--help')
-V, --version Print version
```

## Stargazers over time
Expand Down
Loading
Loading