From ad248b4608ba0d38ea553fdbeb768bae8ba64939 Mon Sep 17 00:00:00 2001
From: AlejandroSuero
Date: Sun, 2 Jun 2024 18:13:26 +0200
Subject: [PATCH 1/6] feat(#100): added `show-cmd` flag to config
---
config.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/config.go b/config.go
index cd572e6..7561ae8 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"`
From f12ed80543c8407caf59beb90152c72d16c67b48 Mon Sep 17 00:00:00 2001
From: AlejandroSuero
Date: Sun, 2 Jun 2024 18:13:49 +0200
Subject: [PATCH 2/6] feat(#100): implemented `show-cmd` flag
---
pty.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/pty.go b/pty.go
index 7c782b8..f0dd10a 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
}
From 37287febf13010348770cdd2e3b18a32dc93d3fe Mon Sep 17 00:00:00 2001
From: AlejandroSuero
Date: Sun, 2 Jun 2024 18:14:47 +0200
Subject: [PATCH 3/6] docs(#100): show `show-cmd` flag demo in `README.md`
---
README.md | 11 +++++++++++
test/golden/svg/show-eza.svg | 15 +++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 test/golden/svg/show-eza.svg
diff --git a/README.md b/README.md
index 533a1de..f990dee 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,16 @@ freeze --execute "eza -lah"
+#### Show executed command
+
+```bash
+freeze --execute "eza -h"
+```
+
+
+
+
+
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/test/golden/svg/show-eza.svg b/test/golden/svg/show-eza.svg
new file mode 100644
index 0000000..2362aef
--- /dev/null
+++ b/test/golden/svg/show-eza.svg
@@ -0,0 +1,15 @@
+
+
+
From d15f79777ddba3d88aadc3833279d711a492a922 Mon Sep 17 00:00:00 2001
From: AlejandroSuero
Date: Sun, 2 Jun 2024 18:55:31 +0200
Subject: [PATCH 4/6] fix: updated `show-eza.svg` with `make golden`
---
freeze_test.go | 5 +++++
test/golden/svg/show-eza.svg | 8 ++++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/freeze_test.go b/freeze_test.go
index 06b4e43..fad6be5 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/test/golden/svg/show-eza.svg b/test/golden/svg/show-eza.svg
index 2362aef..4336c3e 100644
--- a/test/golden/svg/show-eza.svg
+++ b/test/golden/svg/show-eza.svg
@@ -1,6 +1,6 @@
-
From 52b32534be0ed4cf59b1c2b27e567c5e10a8b01b Mon Sep 17 00:00:00 2001
From: AlejandroSuero
Date: Sun, 2 Jun 2024 18:57:40 +0200
Subject: [PATCH 5/6] fix: added `--show-cmd` in `README.md`
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index f990dee..26b1c2a 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ freeze --execute "eza -lah"
#### Show executed command
```bash
-freeze --execute "eza -h"
+freeze --execute "eza -h" --show-cmd
```
From 80f34db639217cfae0666ceb944f4ad5a91eadf8 Mon Sep 17 00:00:00 2001
From: AlejandroSuero
Date: Wed, 5 Jun 2024 15:12:44 +0200
Subject: [PATCH 6/6] fix: formatting
---
freeze_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/freeze_test.go b/freeze_test.go
index fad6be5..5080189 100644
--- a/freeze_test.go
+++ b/freeze_test.go
@@ -127,7 +127,7 @@ func TestFreezeConfigurations(t *testing.T) {
},
{
input: "test/input/eza.ansi",
- flags: []string{"--config", "full", "--show-cmd" },
+ flags: []string{"--config", "full", "--show-cmd"},
output: "show-eza",
},
{