// Input file as a required positional argument
if flags.NArg() == 0 {
return fmt.Errorf("please provide a path to an input file")
+ } else if flags.NArg() > 1 {
+ return fmt.Errorf("please provide just one input file argument")
}
- srcPath := &os.Args[flags.NFlag()+1]
+ srcPath := &os.Args[len(os.Args)-1]
// Validations
if *srcPath == "" {
// Input file as a required positional argument
if flags.NArg() == 0 {
return fmt.Errorf("please provide a path to an input file")
+ } else if flags.NArg() > 1 {
+ return fmt.Errorf("please provide just one input file argument")
}
- srcPath := &os.Args[flags.NFlag()+1]
+ srcPath := &os.Args[len(os.Args)-1]
// Validations
if *srcPath == "" {
}
func (s *TestSuite) TestParseFlagsWrongUserID(c *C) {
- os.Args = []string{"cmd", "-user-id=nickname", "/tmp/somefile.csv"}
+ os.Args = []string{"cmd", "-user-id", "nickname", "/tmp/somefile.csv"}
err := ParseFlags(&ConfigParams{})
c.Assert(err, NotNil)
c.Assert(err, ErrorMatches, ".*user ID must be one of:.*")
func (s *TestSuite) TestParseFlagsWithOptionalFlags(c *C) {
cfg := ConfigParams{}
- os.Args = []string{"cmd", "-verbose", "-deactivate-unlisted", "-user-id=username", "/tmp/somefile.csv"}
+ os.Args = []string{"cmd", "-verbose", "-deactivate-unlisted", "-user-id", "username", "/tmp/somefile.csv"}
err := ParseFlags(&cfg)
c.Assert(err, IsNil)
c.Assert(cfg.Path, Equals, "/tmp/somefile.csv")