Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#100): show CMD for --execute if --show-cmd is added #101

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ freeze --execute "eza -lah"
</a>
</p>

#### Show executed command

```bash
freeze --execute "eza -h" --show-cmd
```

<p align="center">
<img alt="output of freeze command showing executed command, ANSI" src="./test/golden/svg/show-eza.svg" width="800" />
</p>

Freeze is also [super customizable](#customization) and ships with an [interactive TUI](#interactive-mode).

## Installation
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
5 changes: 5 additions & 0 deletions freeze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions pty.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"bytes"
"context"
"fmt"
"io"
"os"
"os/exec"
Expand Down Expand Up @@ -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
}
15 changes: 15 additions & 0 deletions test/golden/svg/show-eza.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.