Skip to content

Commit

Permalink
feat: if input is "-" read stdin
Browse files Browse the repository at this point in the history
Make it compatible with other applications that given the input "-" they read from stdin. This would be a shortcut to specifying "-stdin".
  • Loading branch information
ivanvc committed Aug 4, 2023
1 parent 0de394a commit 216280c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ func Execute(cfg *config.Config) {

func loadInput(cfg *config.Config) (string, error) {
var input string
if len(cfg.InputFile) > 0 {
if len(cfg.InputFile) > 0 && cfg.InputFile != "-" {
b, err := intio.ReadFile(cfg.InputFile)
if err != nil {
return input, err
}
input = string(b)
} else if cfg.UseStdin {
} else if cfg.UseStdin || cfg.InputFile == "-" {
b, err := io.ReadAll(os.Stdin)
if err != nil {
return input, err
Expand Down

0 comments on commit 216280c

Please sign in to comment.