Skip to content

Commit

Permalink
Adding features reporting to diesel_cli (#2724)
Browse files Browse the repository at this point in the history
* --features

Starting to add features flag

* Added diesel_cli compiled features flag

#2717

* clippy correction

println!("");
^^^^^^^^^^^^ help: replace it with: `println!()`

* clippy keeping things nice and consistent

using `!is_empty` is clearer and more explicit: `!features.is_empty()`
 and
unnecessary boolean `not` operation

* Improving based on pull request review

* pull request review improvements

more helpful improvements suggested by pksunkara

* Applying CI Tests / Check rustfmt style

https://github.com/diesel-rs/diesel/pull/2724/checks?check_run_id=2336929398
CI Tests / Check rustfmt style && run clippy (pull_request) seems to be demanding I apply inconsistent formatting, compared with all of the other SubCommands.

* Clearer and more succinct wording

Improved wording suggested by henryboisdequin

* Suggested simplification

#2724 (comment)

* Address the final review commend + also include these information in the
`--version` output

* --features

Starting to add features flag

* Added diesel_cli compiled features flag

#2717

* clippy correction

println!("");
^^^^^^^^^^^^ help: replace it with: `println!()`

* clippy keeping things nice and consistent

using `!is_empty` is clearer and more explicit: `!features.is_empty()`
 and
unnecessary boolean `not` operation

* Improving based on pull request review

* pull request review improvements

more helpful improvements suggested by pksunkara

* Applying CI Tests / Check rustfmt style

https://github.com/diesel-rs/diesel/pull/2724/checks?check_run_id=2336929398
CI Tests / Check rustfmt style && run clippy (pull_request) seems to be demanding I apply inconsistent formatting, compared with all of the other SubCommands.

* Clearer and more succinct wording

Improved wording suggested by henryboisdequin

* Suggested simplification

#2724 (comment)

* Address the final review commend + also include these information in the
`--version` output

* Remove explicit feature subcommand

It's not required if we just emit the relevant infos in `diesel --version`

---------

Co-authored-by: Alexx Roche <notice-dev@alexx.net>
Co-authored-by: Georg Semmler <github@weiznich.de>
  • Loading branch information
3 people authored Mar 20, 2023
1 parent af9f79e commit adda7f9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion diesel_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ doc = false

[dependencies]
chrono = { version = "0.4.19", default-features = false, features = ["clock", "std"] }
clap = "4.0.2"
clap = { version = "4.0.2", features = ["cargo", "string"] }
clap_complete = "4"
dotenvy = "0.15"
heck = "0.4.0"
Expand Down
11 changes: 10 additions & 1 deletion diesel_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,16 @@ pub fn build_cli() -> Command {
.global(true);

Command::new("diesel")
.version(env!("CARGO_PKG_VERSION"))
.version(clap::crate_version!())
.long_version(
clap::builder::Str::from(
format!(
"\n Version: {}\n Supported Backends: {}",
clap::crate_version!(),
super::supported_backends()
)
)
)
.after_help(
"You can also run `diesel SUBCOMMAND -h` to get more information about that subcommand.",
)
Expand Down
13 changes: 13 additions & 0 deletions diesel_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,19 @@ fn regenerate_schema_if_file_specified(
Ok(())
}

fn supported_backends() -> String {
let features = &[
#[cfg(feature = "postgres")]
"postgres",
#[cfg(feature = "mysql")]
"mysql",
#[cfg(feature = "sqlite")]
"sqlite",
];

features.join(" ")
}

#[cfg(test)]
mod tests {
extern crate tempfile;
Expand Down

0 comments on commit adda7f9

Please sign in to comment.