diff --git a/Cargo.lock b/Cargo.lock index 961e4bf..b27dd2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -845,7 +845,7 @@ dependencies = [ [[package]] name = "jnv" -version = "0.5.0" +version = "0.6.0" dependencies = [ "anyhow", "arboard", diff --git a/Cargo.toml b/Cargo.toml index 3c42847..1baf196 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jnv" -version = "0.5.0" +version = "0.6.0" authors = ["ynqa "] edition = "2021" description = "JSON navigator and interactive filter leveraging jq" diff --git a/README.md b/README.md index 8867199..c09b503 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ Text describing the image - [![ci](https://github.com/ynqa/jnv/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ynqa/jnv/actions/workflows/ci.yml) *jnv* is designed for navigating JSON, @@ -19,23 +18,16 @@ and [jiq](https://github.com/fiatjaf/jiq). - Interactive JSON viewer and `jq` filter editor - Syntax highlighting for JSON - Use [jaq](https://github.com/01mf02/jaq) to apply `jq` filter - - This eliminates the need for users to prepare `jq` on their own. - -> [!IMPORTANT] -> Starting from v0.3.0, the transition from libjq Rust binding -> [j9](https://github.com/ynqa/j9) to jq clone -> [jaq](https://github.com/01mf02/jaq) was made. -> -> This change eliminated the need to manage C-related dependencies -> that include external tools like autoconf, thus simplifying the build process. -> However, please note that some filters are not yet supported by jaq. -> For more details, refer to GitHub issue -> [#24](https://github.com/ynqa/jnv/issues/24). -> -> Please continue to provide feedback regarding this transition. - + - This eliminates the need for users to prepare `jq` on their own +- Configurable features via TOML configuration + - Toggle hint message display + - Adjust UI reactivity (debounce times and animation speed) + - Editor appearance and behavior + - JSON viewer styling + - Adjust completion feature display and behavior + - Keybinds - Capable of accommodating various format - - Input: File, Stdin + - Input: File, stdin - Data: A JSON or multiple JSON structures that can be deserialized with [StreamDeserializer](https://docs.rs/serde_json/latest/serde_json/struct.StreamDeserializer.html), @@ -49,6 +41,8 @@ and [jiq](https://github.com/fiatjaf/jiq). ## Installation +[![Packaging status](https://repology.org/badge/vertical-allrepos/jnv.svg)](https://repology.org/project/jnv/versions) + ### Homebrew See [here](https://formulae.brew.sh/formula/jnv) for more info. @@ -169,7 +163,7 @@ jnv data.json ## Usage ```bash -SON navigator and interactive filter leveraging jq +JSON navigator and interactive filter leveraging jq Usage: jnv [OPTIONS] [INPUT] @@ -184,14 +178,125 @@ 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 for the interface ('insert' or 'overwrite'). [default: insert] - -i, --indent Number of spaces used for indentation in the visualized data. [default: 2] - -n, --no-hint Disables the display of hints. - --max-streams Maximum number of JSON streams to display - --suggestions Number of autocomplete suggestions to show [default: 3] - -h, --help Print help (see more with '--help') - -V, --version Print version + -c, --config Path to the configuration file. + --default-filter Default jq filter to apply to the input data + -h, --help Print help (see more with '--help') + -V, --version Print version ``` +## Configuration + +jnv uses a TOML format configuration file to customize various features. +The configuration file is loaded in the following order of priority: + +1. Path specified on the command line (`-c` or `--config` option) +2. Default configuration file path + +### Default Configuration File Location + +Following the `dirs` crate, +the default configuration file location for each platform is as follows: + +- **Linux**: `~/.config/jnv/config.toml` +- **macOS**: `~/Library/Application Support/jnv/config.toml` +- **Windows**: `C:\Users\{Username}\AppData\Roaming\jnv\config.toml` + +If the configuration file does not exist, +it will be automatically created on first run. + +### Configuration Options + +The following settings are available in `config.toml`: + +```toml +# Whether to hide the hint message +no_hint = false + +# Editor settings +[editor] +# Editor mode ("Insert" or "Overwrite") +mode = "Insert" +# Word break characters +word_break_chars = [".", "|", "(", ")", "[", "]"] + +# Theme when editor is focused +[editor.theme_on_focus] +prefix = "❯❯ " +prefix_style = { foreground = "blue" } +active_char_style = { background = "magenta" } +inactive_char_style = {} + +# Theme when editor is not focused +[editor.theme_on_defocus] +prefix = "▼ " +prefix_style = { foreground = "blue", attributes = ["Dim"] } +active_char_style = { attributes = ["Dim"] } +inactive_char_style = { attributes = ["Dim"] } + +# JSON display settings +[json] +# Maximum number of JSON objects to read from stream +# max_streams = + +# JSON theme settings +[json.theme] +indent = 2 +curly_brackets_style = { attributes = ["Bold"] } +square_brackets_style = { attributes = ["Bold"] } +key_style = { foreground = "cyan" } +string_value_style = { foreground = "green" } +number_value_style = {} +boolean_value_style = {} +null_value_style = { foreground = "grey" } + +# Completion feature settings +[completion] +lines = 3 +cursor = "❯ " +active_item_style = { foreground = "grey", background = "yellow" } +inactive_item_style = { foreground = "grey" } +search_result_chunk_size = 100 +search_load_chunk_size = 50000 + +# Keybind settings +[keybinds] +# Application exit key +exit = [{ Key = { modifiers = "CONTROL", code = { Char = "c" } } }] +# Copy query to clipboard key +copy_query = [{ Key = { modifiers = "CONTROL", code = { Char = "q" } } }] +# Copy result to clipboard key +copy_result = [{ Key = { modifiers = "CONTROL", code = { Char = "o" } } }] +# Mode switch keys +switch_mode = [ + { Key = { code = "Down", modifiers = "SHIFT" } }, + { Key = { code = "Up", modifiers = "SHIFT" } } +] + +# Editor operation keybinds +[keybinds.on_editor] +# (Details omitted) + +# JSON viewer keybinds +[keybinds.on_json_viewer] +# (Details omitted) + +# Application reactivity settings +[reactivity_control] +# Delay time after query input +query_debounce_duration = "600ms" +# Redraw delay time after window resize +resize_debounce_duration = "200ms" +# Spinner animation update interval +spin_duration = "300ms" +``` + +For more details on configuration, please refer to [default.toml](./default.toml) + +> [!WARNING] +> Depending on the type of terminal and environment, +> characters and styles may not be displayed properly. +> Specific key bindings and decorative characters may not +> display or function correctly in certain terminal emulators. + ## Stargazers over time [![Stargazers over time](https://starchart.cc/ynqa/jnv.svg?variant=adaptive)](https://starchart.cc/ynqa/jnv)