Skip to content

Commit

Permalink
Add mising error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuoza committed Feb 24, 2021
1 parent 3be4355 commit 8e95bf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cmd/switchbot/command/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ func (c *InfoCommand) parseArgs(args []string) (*infoCfg, int) {
flags.Usage = func() {
c.UI.Info(c.Help())
}
flags.Parse(args)

if err := flags.Parse(args); err != nil {
return cfg, 127
}

args = flags.Args()
if len(args) != 1 || (cfg.Format != "table" && cfg.Format != "json") {
Expand Down
5 changes: 4 additions & 1 deletion cmd/switchbot/command/press.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func (c *PressCommand) parseArgs(args []string) (*pressCfg, int) {
flags.Usage = func() {
c.UI.Info(c.Help())
}
flags.Parse(args)

if err := flags.Parse(args); err != nil {
return cfg, 127
}

args = flags.Args()
if len(args) != 1 {
Expand Down
4 changes: 3 additions & 1 deletion cmd/switchbot/command/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func (c *ScanCommand) parseArgs(args []string) (*scanCfg, int) {
flags.Usage = func() {
c.UI.Info(c.Help())
}
flags.Parse(args)
if err := flags.Parse(args); err != nil {
return cfg, 127
}
return cfg, 0
}

Expand Down

0 comments on commit 8e95bf1

Please sign in to comment.