Skip to content

Adding Global Flag in Modern CLI #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/modern/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Root struct {
configFilename string
loggingLevel int
outputType string
inputType string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputType string

why is this a root level parameter?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question. Where should we put all these back-compat switches. They are needed either when the customer uses the query subcommand, or when the use uses no subcommand (which is defined in this Root type!).

Should we add all these back-compat switches to the Query subcommand, and then have them accessable to the Root when no subcommand is provided.

}

// DefineCommand defines the top-level sqlcmd sub-commands.
Expand Down Expand Up @@ -113,4 +114,12 @@ func (c *Root) addGlobalFlags() {
Shorthand: "v",
Usage: "Log level, error=0, warn=1, info=2, debug=3, trace=4",
})

c.AddFlag(cmdparser.FlagOptions{
String: &c.inputType,
DefaultString: "yaml",
Name: "InputFile",
Shorthand: "i",
Usage: "output type (yaml, json or xml)",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this implies 3 different concepts -

  1. input type
  2. input file name
  3. Output type

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a copy and paste error (from outputType above)

})
}