From ea2d72ef02ca7ebc151e046ecdc405d7477dafda Mon Sep 17 00:00:00 2001 From: Tim Shilov Date: Sun, 19 Oct 2025 14:50:31 +0100 Subject: [PATCH] feat: added '--show-input-panel' CLI argument --- cmd/root.go | 19 ++++++++++++------- snap/snapcraft.yaml | 13 +++++++------ tui/bubbles/help/help.go | 4 ++-- tui/bubbles/jqplayground/model.go | 6 +++--- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index b1b2197..91a17a3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -68,7 +68,7 @@ You can provide the input JSON or NDJSON either through a file or via standard i if err != nil { return err } - bubble, err := jqplayground.New(stdin, "STDIN", query, jqtheme) + bubble, err := jqplayground.New(stdin, "STDIN", query, jqtheme, flags.showInputPanel) if err != nil { return err } @@ -102,7 +102,7 @@ You can provide the input JSON or NDJSON either through a file or via standard i return err } - bubble, err := jqplayground.New(data, fi.Name(), query, jqtheme) + bubble, err := jqplayground.New(data, fi.Name(), query, jqtheme, flags.showInputPanel) if err != nil { return err } @@ -154,15 +154,18 @@ func initConfig() { var flags struct { filepath, theme string + showInputPanel bool } var flagsName = struct { - file, fileShort, theme, themeShort string + file, fileShort, theme, themeShort, showInputPanel, showInputPanelShort string }{ - file: "file", - fileShort: "f", - theme: "theme", - themeShort: "t", + file: "file", + fileShort: "f", + theme: "theme", + themeShort: "t", + showInputPanel: "show-input-panel", + showInputPanelShort: "i", } var configKeysName = struct { @@ -194,5 +197,7 @@ func Execute() error { flagsName.themeShort, "", "jqp theme") + rootCmd.Flags().BoolVarP(&flags.showInputPanel, flagsName.showInputPanel, flagsName.showInputPanelShort, true, "show input panel") + return rootCmd.Execute() } diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 69ee8dd..90ca184 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -16,12 +16,13 @@ description: | jqp [query] [flags] Flags: - --config string path to config file (default is $HOME/.jqp.yaml) - -f, --file string path to the input JSON file - -h, --help help for jqp - -t, --theme string jqp theme - -v, --version version for jqp - + --config string path to config file (default is $HOME/.jqp.yaml) + -f, --file string path to the input JSON file + -h, --help help for jqp + -i, --show-input-panel show input panel (default true) + -t, --theme string jqp theme + -v, --version version for jqp + license: MIT issues: https://github.com/kz6fittycent/jqp contact: https://github.com/kz6fittycent/jqp diff --git a/tui/bubbles/help/help.go b/tui/bubbles/help/help.go index 086fd7f..668f27d 100644 --- a/tui/bubbles/help/help.go +++ b/tui/bubbles/help/help.go @@ -17,7 +17,7 @@ type Bubble struct { showInputPanel bool } -func New(jqtheme theme.Theme) Bubble { +func New(jqtheme theme.Theme, showInputPanel bool) Bubble { styles := DefaultStyles() model := help.New() model.Styles.ShortKey = styles.helpKeyStyle.Foreground(jqtheme.Primary) @@ -29,7 +29,7 @@ func New(jqtheme theme.Theme) Bubble { Styles: styles, help: model, keys: keys, - showInputPanel: true, // Default to showing input panel + showInputPanel: showInputPanel, } } diff --git a/tui/bubbles/jqplayground/model.go b/tui/bubbles/jqplayground/model.go index 04bc7d5..98e951f 100644 --- a/tui/bubbles/jqplayground/model.go +++ b/tui/bubbles/jqplayground/model.go @@ -37,7 +37,7 @@ type Bubble struct { showInputPanel bool } -func New(inputJSON []byte, filename string, query string, jqtheme theme.Theme) (Bubble, error) { +func New(inputJSON []byte, filename string, query string, jqtheme theme.Theme, showInputPanel bool) (Bubble, error) { workingDirectory, err := os.Getwd() if err != nil { return Bubble{}, err @@ -64,11 +64,11 @@ func New(inputJSON []byte, filename string, query string, jqtheme theme.Theme) ( queryinput: queryInput, inputdata: inputData, output: output.New(jqtheme), - help: help.New(jqtheme), + help: help.New(jqtheme, showInputPanel), statusbar: sb, fileselector: fs, theme: jqtheme, - showInputPanel: true, + showInputPanel: showInputPanel, } return b, nil }