File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package cmd
22
33import (
4- "fmt "
4+ "strconv "
55
66 "github.com/github/gh-stack/internal/config"
77 "github.com/github/gh-stack/internal/git"
@@ -16,7 +16,12 @@ func UpCmd(cfg *config.Config) *cobra.Command {
1616 RunE : func (cmd * cobra.Command , args []string ) error {
1717 n := 1
1818 if len (args ) > 0 {
19- fmt .Sscanf (args [0 ], "%d" , & n )
19+ var err error
20+ n , err = strconv .Atoi (args [0 ])
21+ if err != nil {
22+ cfg .Errorf ("invalid number %q" , args [0 ])
23+ return ErrInvalidArgs
24+ }
2025 }
2126 return runNavigate (cfg , n )
2227 },
@@ -31,7 +36,12 @@ func DownCmd(cfg *config.Config) *cobra.Command {
3136 RunE : func (cmd * cobra.Command , args []string ) error {
3237 n := 1
3338 if len (args ) > 0 {
34- fmt .Sscanf (args [0 ], "%d" , & n )
39+ var err error
40+ n , err = strconv .Atoi (args [0 ])
41+ if err != nil {
42+ cfg .Errorf ("invalid number %q" , args [0 ])
43+ return ErrInvalidArgs
44+ }
3545 }
3646 return runNavigate (cfg , - n )
3747 },
You can’t perform that action at this time.
0 commit comments