Skip to content

Commit

Permalink
Merge pull request #139 from catatsuy/feature_add_os_stdout_is_terminal
Browse files Browse the repository at this point in the history
Add check for input file in CLI Run method
  • Loading branch information
catatsuy authored Mar 20, 2024
2 parents 6547b62 + 08d0ecc commit e9d01f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/catatsuy/notify_slack/config"
"github.com/catatsuy/notify_slack/slack"
"github.com/catatsuy/notify_slack/throttle"
"golang.org/x/term"
)

var (
Expand Down Expand Up @@ -106,6 +107,9 @@ func (c *CLI) Run(args []string) int {
fmt.Fprintln(c.errStream, "You cannot pass multiple files")
return ExitCodeParseFlagError
}
} else if term.IsTerminal(int(os.Stdin.Fd())) {
fmt.Fprintln(c.errStream, "No input file specified")
return ExitCodeFail
}

tomlFile = config.LoadTOMLFilename(tomlFile)
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ module github.com/catatsuy/notify_slack
go 1.19

require github.com/pelletier/go-toml/v2 v2.2.0

require (
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down

0 comments on commit e9d01f7

Please sign in to comment.