diff --git a/README.md b/README.md index 533a1de5..26b1c2ab 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,16 @@ freeze --execute "eza -lah"

+#### Show executed command + +```bash +freeze --execute "eza -h" --show-cmd +``` + +

+ output of freeze command showing executed command, ANSI +

+ Freeze is also [super customizable](#customization) and ships with an [interactive TUI](#interactive-mode). ## Installation @@ -95,6 +105,7 @@ Screenshots can be customized with `--flags` or [Configuration](#configuration) - [`-b`](#background), [`--background`](#background): Apply a background fill. - [`-c`](#configuration), [`--config`](#configuration): Base configuration file or template. +- [`-s`](#show-executed-command), [`--show-cmd`](#show-executed-command): Show executed command. - [`-l`](#language), [`--language`](#language): Language to apply to code - [`-m`](#margin), [`--margin`](#margin): Apply margin to the window. - [`-o`](#output), [`--output`](#output): Output location for .svg, .png, .jpg. diff --git a/config.go b/config.go index cd572e6a..7561ae8b 100644 --- a/config.go +++ b/config.go @@ -27,6 +27,7 @@ type Config struct { // Settings Config string `json:"config,omitempty" help:"Base configuration file or template." short:"c" group:"Settings" default:"default" placeholder:"base"` + ShowCmd bool `json:"show_cmd" help:"Show executed command." short:"s" group:"Settings" placeholder:"false"` Interactive bool `hidden:"" json:",omitempty" help:"Use an interactive form for configuration options." short:"i" group:"Settings"` Language string `json:"language,omitempty" help:"Language of code file." short:"l" group:"Settings" placeholder:"go"` Theme string `json:"theme" help:"Theme to use for syntax highlighting." short:"t" group:"Settings" placeholder:"charm"` diff --git a/freeze_test.go b/freeze_test.go index 06b4e439..50801896 100644 --- a/freeze_test.go +++ b/freeze_test.go @@ -125,6 +125,11 @@ func TestFreezeConfigurations(t *testing.T) { flags: []string{"--config", "full"}, output: "eza", }, + { + input: "test/input/eza.ansi", + flags: []string{"--config", "full", "--show-cmd"}, + output: "show-eza", + }, { flags: []string{"--execute", `echo "Hello, world!"`}, output: "execute", diff --git a/pty.go b/pty.go index 7c782b8f..f0dd10a6 100644 --- a/pty.go +++ b/pty.go @@ -6,6 +6,7 @@ package main import ( "bytes" "context" + "fmt" "io" "os" "os/exec" @@ -49,5 +50,8 @@ func executeCommand(config Config) (string, error) { if err != nil { return "", err } + if config.ShowCmd { + return fmt.Sprintf("%s\n\n%s", config.Execute, out.String()), nil + } return out.String(), nil } diff --git a/test/golden/svg/show-eza.svg b/test/golden/svg/show-eza.svg new file mode 100644 index 00000000..4336c3eb --- /dev/null +++ b/test/golden/svg/show-eza.svg @@ -0,0 +1,15 @@ + + + + + +ansi.go cut_test.go go.mod main.go style.goconfig.go error.go go.sum Makefile svgconfig_test.go font help.go png.go tapesconfigurations font.go input pty.go testcut.go freeze_test.go interactive.go README.md + +