From affff682936b28e6467544f5da238f5eee1d357f Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 17 Apr 2024 18:30:13 +0100 Subject: [PATCH 1/3] feat: include command config option Co-authored-by: Swastik --- config.go | 1 + main.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 09448f0..5b33077 100644 --- a/config.go +++ b/config.go @@ -33,6 +33,7 @@ type Config struct { Output string `json:"output,omitempty" help:"Output location for {{.svg}}, {{.png}}, or {{.webp}}." short:"o" group:"Settings" default:"" placeholder:"freeze.svg"` Execute string `json:"-" help:"Capture output of command execution." short:"x" group:"Settings" default:""` + IncludeCmd bool `json:"-" help:"Include the command to be executed in the generated image" group:"Settings" default:"false"` ExecuteTimeout time.Duration `json:"-" help:"Execution timeout." group:"Settings" default:"10s" prefix:"execute." name:"timeout" hidden:""` // Decoration diff --git a/main.go b/main.go index 3675a47..5c098d7 100644 --- a/main.go +++ b/main.go @@ -61,7 +61,6 @@ func main() { if len(ctx.Args) > 0 { switch ctx.Args[0] { - case "version": if Version == "" { if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" { @@ -89,6 +88,9 @@ func main() { if input == "" { printErrorFatal("Something went wrong", errors.New("no command output")) } + if config.IncludeCmd { + input = "$ " + config.Execute + "\n" + input + } } isDefaultConfig := config.Config == "default" From 02a4c7b6b4d38fe3f45bcdf3b2d681868aac187b Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 24 Apr 2024 21:33:13 +0100 Subject: [PATCH 2/3] refactor: use suggestions --- config.go | 2 +- main.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index 5b33077..b116194 100644 --- a/config.go +++ b/config.go @@ -33,7 +33,7 @@ type Config struct { Output string `json:"output,omitempty" help:"Output location for {{.svg}}, {{.png}}, or {{.webp}}." short:"o" group:"Settings" default:"" placeholder:"freeze.svg"` Execute string `json:"-" help:"Capture output of command execution." short:"x" group:"Settings" default:""` - IncludeCmd bool `json:"-" help:"Include the command to be executed in the generated image" group:"Settings" default:"false"` + Command bool `json:"-" help:"Include the command to be executed in the generated image" group:"Settings" default:"true" prefix:"execute." hidden:""` ExecuteTimeout time.Duration `json:"-" help:"Execution timeout." group:"Settings" default:"10s" prefix:"execute." name:"timeout" hidden:""` // Decoration diff --git a/main.go b/main.go index 5c098d7..92b6f91 100644 --- a/main.go +++ b/main.go @@ -88,8 +88,8 @@ func main() { if input == "" { printErrorFatal("Something went wrong", errors.New("no command output")) } - if config.IncludeCmd { - input = "$ " + config.Execute + "\n" + input + if config.Command { + input = "> " + config.Execute + "\n" + input } } From 608e16729fa8f5d39319b6426cad867a40d4b569 Mon Sep 17 00:00:00 2001 From: isabel Date: Wed, 24 Apr 2024 22:11:16 +0100 Subject: [PATCH 3/3] chore: update execute test svg --- test/golden/svg/execute.svg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/golden/svg/execute.svg b/test/golden/svg/execute.svg index 2811ee7..ddfa619 100644 --- a/test/golden/svg/execute.svg +++ b/test/golden/svg/execute.svg @@ -1,6 +1,6 @@ - + + -Hello, world! +> echo "Hello, world!"Hello, world!