Skip to content
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

Adding Global Flag in Modern CLI #180

Closed
wants to merge 1 commit into from
Closed

Conversation

JyotikaGargg
Copy link
Contributor

In order to migrate all the commands from Kong to Modern CLI,
I have started with one flag here : InputFile.

@JyotikaGargg JyotikaGargg marked this pull request as draft December 29, 2022 10:33
@@ -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.

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)

@shueybubbles
Copy link
Collaborator

The sqlcmd package defines the main parameter structure for the query command, here https://github.com/microsoft/go-sqlcmd/blob/main/pkg/sqlcmd/connect.go

What I think you would do is update query.go here https://github.com/microsoft/go-sqlcmd/blob/main/cmd/modern/root/query.go to define the new modern command structure. That command implementation will construct a Connect object to pass to the Sqlcmd instance to do its work.
modern/root/query.go will eventually replace cmd/sqlcmd/sqlcmd.go

@stuartpa
Copy link
Collaborator

I've added discussion #193 to work through how we do this, we can use this PR as a proof point.

Part of the issue here is we need to make, in this case, the -i switch available on the root command (for back-compat), and on the query subcommand. What's the best way to wire this up. Add the -i flag to query.go, and somehow provide a mechanism to also have it made available on the root command (when no sub-command is presented).

We also need to deal with when to show help. Presuming we make it so the -i command works when no sub-command is added, should we show help for -i when sqlcmd --help is run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants