Skip to content

Modern CLI is getting invoked in spite of missing verbs #183

@apoorvdeshmukh

Description

@apoorvdeshmukh

@JyotikaGargg and I found this issue in main.go where we read the 2nd argument even if os.Args contains just 1 argument i.e. when no argument is specified to sqlcmd.exe

if len(os.Args) > 0 {
		if rootCmd.IsValidSubCommand(os.Args[1]) {
			isNewCliCommand = true
		}
	}
\go-sqlcmd\cmd\modern>go build -o sqlcmd.exe
\go-sqlcmd\cmd\modern>.\sqlcmd.exe
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
main.isFirstArgModernCliSubCommand(...)
        C:/Users/apdeshmukh/git/go-sqlcmd/cmd/modern/main.go:53
main.main()
        C:/Users/apdeshmukh/git/go-sqlcmd/cmd/modern/main.go:41 +0x245

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions