Skip to content

Commit

Permalink
set stdin as defaumt input if there is piped data
Browse files Browse the repository at this point in the history
  • Loading branch information
kpym committed Oct 22, 2024
1 parent 61e47e7 commit 8754227
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gm_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,14 @@ func setBuildParameters() {
inpatterns = pflag.Args()
// check for positional parameters
if len(inpatterns) == 0 {
pflag.Usage()
check(errors.New("at least one input 'file.md', 'p*ttern' or 'stdin' should be provided"))
// check if there is a pipeed input
stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
inpatterns = append(inpatterns, "stdin")
} else {
pflag.Usage()
check(errors.New("at least one input 'file.md', 'p*ttern' or 'stdin' should be provided"))
}
}

// check the "out dir"
Expand Down

0 comments on commit 8754227

Please sign in to comment.