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

Unify cli input parsing #549

Merged
merged 1 commit into from Mar 4, 2020
Merged

Unify cli input parsing #549

merged 1 commit into from Mar 4, 2020

Conversation

pimeys
Copy link
Contributor

@pimeys pimeys commented Mar 3, 2020

  • Version command displays the binary name and commit id everywhere
  • All long cli params are now kebab-case instead of snake_case, the standard
  • The prisma-fmt has now subcommands format and lint instead of one
    boolean flag lint that when set lints and when not set formats.

This requires us to change the vscode plugin and prisma-client and prisma2 cli to support the new options.

@pimeys pimeys requested review from mavilein and tomhoule March 3, 2020 17:06
@pimeys
Copy link
Contributor Author

pimeys commented Mar 3, 2020

Addresses issue #521

Copy link
Contributor

@tomhoule tomhoule left a comment

Choose a reason for hiding this comment

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

It's obvious but I wanted to point out it's a breaking change for the frontend, so it has to be coordinated with them.

The last thing I think is awkward with our CLIs is that subcommands take a -- (like migration-engine --can-connect-to-database instead of migration-engine can-connect-to-database 'dev.db'), which is kind of unusual.

use structopt::StructOpt;

#[derive(Debug, StructOpt, Clone)]
#[structopt(version = env!("GIT_HASH"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

oh I didn't know that option, it's great!

stdin: bool,
/// Whether to ignore warnings from the migration engine regarding data loss. Default: false.
#[structopt(long = "force")]
#[structopt(long)]
Copy link
Contributor

Choose a reason for hiding this comment

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

didn't know that either, great!

fn main() {
match FmtOpts::from_args() {
FmtOpts::Lint(opts) => lint::run(opts),
FmtOpts::Format(opts) => format::run(opts),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

much better 💯

@pimeys
Copy link
Contributor Author

pimeys commented Mar 3, 2020

It's obvious but I wanted to point out it's a breaking change for the frontend, so it has to be coordinated with them.

The last thing I think is awkward with our CLIs is that subcommands take a -- (like migration-engine --can-connect-to-database instead of migration-engine can-connect-to-database 'dev.db'), which is kind of unusual.

Yeah. But this way we have to provide only one of them. If this would be a struct, you could provide both but then the code would decide the order, like only execute --can-connect-to-database even if --create-database is set. Which is weird.

@tomhoule
Copy link
Contributor

tomhoule commented Mar 3, 2020

Yep I meant not making non-subcommands, but removing the -- (ideally).

@pimeys
Copy link
Contributor Author

pimeys commented Mar 3, 2020 via email

@tomhoule
Copy link
Contributor

tomhoule commented Mar 3, 2020

wait, I meant like the subcommands better without -- - if we're doing a breaking change anyway might as well do this too^^

@pimeys
Copy link
Contributor Author

pimeys commented Mar 3, 2020

wait, I meant like the subcommands better without -- - if we're doing a breaking change anyway might as well do this too^^

Yes. Actually. You're right. Let's go this way.

@pimeys pimeys added this to the Preview 24 New milestone Mar 3, 2020
@pimeys pimeys force-pushed the unified-cli-param-handling branch from 56404d1 to 4ec1451 Compare March 3, 2020 18:36
@pimeys pimeys self-assigned this Mar 4, 2020
- Version command displays the binary name and commit id everywhere
- All long cli params are now kebab-case instead of snake_case, the standard
- The prisma-fmt has now subcommands `format` and `lint` instead of one
  boolean flag `lint` that when set lints and when not set formats.
@pimeys pimeys force-pushed the unified-cli-param-handling branch from 4ec1451 to 9ebc450 Compare March 4, 2020 11:30
@pimeys pimeys merged commit 88ff4c7 into master Mar 4, 2020
@pimeys pimeys deleted the unified-cli-param-handling branch March 4, 2020 11:32
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.

None yet

2 participants