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

Implement most of the Diesel CLI for 0.4.0 #79

Merged
merged 1 commit into from
Jan 8, 2016
Merged

Conversation

sgrif
Copy link
Member

@sgrif sgrif commented Jan 7, 2016

This adds all the plumbing, and 3 of the 4 commands that I want to ship
with the CLI for 0.4.0. This adds the ability to run, revert, and redo
migrations.

There's still a lot of things I'd like to improve about the CLI. We need
to give better error output in cases where something unexpected happens,
and I'd like to proxy unknown subcommands to diesel-subcommand (this
last one appears to be a limitation of
clap
.

I've opted to make diesel_cli be a separate crate, as cargo doesn't
allow you to declare dependencies as only for executables. I don't want
to add clap or chrono (which I'll be adding as a dependency in the
follow up to this commit) to become hard dependencies of diesel itself.

Another unrelated enhancement I'd like to eventually make is adding
dotenv support. I think this should be optional, but if it doesn't
become a hard dependency of diesel itself, maybe it doesn't matter?

@sgrif
Copy link
Member Author

sgrif commented Jan 7, 2016

@mfpiccolo @samphippen @mcasper Review?

@sgrif sgrif force-pushed the sg-diesel-cli branch 2 times, most recently from 0781243 to 8980650 Compare January 7, 2016 19:06
.unwrap();
}
("redo", Some(args)) => {
let connection = connection(&database_url(args));
Copy link
Contributor

Choose a reason for hiding this comment

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

this branch is at a different level of abstraction than the others. What do you think about extracting this into a function also?

Copy link
Member Author

Choose a reason for hiding this comment

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

If anything I'm actually thinking of moving the other branches down. I don't like having #[doc(hidden)] public functions in the main library, and really the only "public" use case I can see is running pending migrations as part of your build script.

Copy link
Contributor

Choose a reason for hiding this comment

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

given that this is main.rs, are any of the things in here actually public?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, that's what I mean. I'd rather move more of the logic into here and out of diesel proper.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah ok. Either way, this is mostly fine, it just caught me as a little odd that the branches weren't balanced. Do with that information what your much better informed than me self wants to do :)

@mfpiccolo
Copy link
Contributor

Code looks good to me. What are the steps for running the commands from a project directory?

@sgrif
Copy link
Member Author

sgrif commented Jan 8, 2016

You can cargo install it

On Fri, Jan 8, 2016, 12:04 AM Mike Piccolo [email protected] wrote:

Code looks good to me. What are the steps for running the commands from a
project directory?


Reply to this email directly or view it on GitHub
#79 (comment).

This adds all the plumbing, and 3 of the 4 commands that I want to ship
with the CLI for 0.4.0. This adds the ability to run, revert, and redo
migrations.

There's still a lot of things I'd like to improve about the CLI. We need
to give better error output in cases where something unexpected happens,
and I'd like to proxy unknown subcommands to `diesel-subcommand` (this
last one appears to be [a limitation of
clap](clap-rs/clap#372).

I've opted to make `diesel_cli` be a separate crate, as cargo doesn't
allow you to declare dependencies as only for executables. I don't want
to add `clap` or `chrono` (which I'll be adding as a dependency in the
follow up to this commit) to become hard dependencies of diesel itself.

Another unrelated enhancement I'd like to eventually make is adding
`dotenv` support. I think this should be optional, but if it doesn't
become a hard dependency of diesel itself, maybe it doesn't matter?
@sgrif sgrif merged commit e5e28f8 into master Jan 8, 2016
@sgrif sgrif deleted the sg-diesel-cli branch January 8, 2016 21:24
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.

3 participants