Skip to content

Commit

Permalink
Merge pull request #142 from cxfcxf/change_output
Browse files Browse the repository at this point in the history
Print out executed command by default
  • Loading branch information
RamiAwar committed Feb 7, 2024
2 parents bed4fc6 + cf11afa commit 068cbf5
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"strings"

"github.com/fatih/color"
"github.com/knqyf263/pet/config"
"github.com/spf13/cobra"
"gopkg.in/alessio/shellescape.v1"
Expand All @@ -32,12 +31,10 @@ func execute(cmd *cobra.Command, args []string) (err error) {
return err
}
command := strings.Join(commands, "; ")
if config.Flag.Debug {
fmt.Printf("Command: %s\n", command)
}
if config.Flag.Command {
fmt.Printf("%s: %s\n", color.YellowString("Command"), command)
}

// Show final command before executing it
fmt.Printf("> %s\n", command)

return run(command, os.Stdin, os.Stdout)
}

Expand All @@ -49,6 +46,4 @@ func init() {
`Initial value for query`)
execCmd.Flags().StringVarP(&config.Flag.FilterTag, "tag", "t", "",
`Filter tag`)
execCmd.Flags().BoolVarP(&config.Flag.Command, "command", "c", false,
`Show the command with the plain text before executing`)
}

0 comments on commit 068cbf5

Please sign in to comment.