Add clap to plume in order to print help and version (#631)

* Add clap in order to print help and version

Related to https://github.com/Plume-org/Plume/issues/594

* Update after_help text message
This commit is contained in:
Wilfried OLLIVIER 2019-07-03 20:36:42 +02:00 committed by Baptiste Gelez
parent 5289fe872a
commit c031804464
3 changed files with 17 additions and 0 deletions

1
Cargo.lock generated
View File

@ -1879,6 +1879,7 @@ dependencies = [
"askama_escape 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "askama_escape 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atom_syndication 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "atom_syndication 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -8,6 +8,7 @@ repository = "https://github.com/Plume-org/Plume"
activitypub = "0.1.3" activitypub = "0.1.3"
askama_escape = "0.1" askama_escape = "0.1"
atom_syndication = "0.6" atom_syndication = "0.6"
clap = "2.33"
colored = "1.8" colored = "1.8"
dotenv = "0.14" dotenv = "0.14"
gettext = { git = "https://github.com/Plume-org/gettext/", rev = "294c54d74c699fbc66502b480a37cc66c1daa7f3" } gettext = { git = "https://github.com/Plume-org/gettext/", rev = "294c54d74c699fbc66502b480a37cc66c1daa7f3" }

View File

@ -5,6 +5,7 @@ extern crate activitypub;
extern crate askama_escape; extern crate askama_escape;
extern crate atom_syndication; extern crate atom_syndication;
extern crate chrono; extern crate chrono;
extern crate clap;
extern crate colored; extern crate colored;
extern crate ctrlc; extern crate ctrlc;
extern crate diesel; extern crate diesel;
@ -38,6 +39,7 @@ extern crate validator;
extern crate validator_derive; extern crate validator_derive;
extern crate webfinger; extern crate webfinger;
use clap::App;
use diesel::r2d2::ConnectionManager; use diesel::r2d2::ConnectionManager;
use plume_models::{ use plume_models::{
db_conn::{DbPool, PragmaForeignKey}, db_conn::{DbPool, PragmaForeignKey},
@ -89,6 +91,19 @@ fn init_pool() -> Option<DbPool> {
} }
fn main() { fn main() {
App::new("Plume")
.bin_name("plume")
.version(env!("CARGO_PKG_VERSION"))
.about("Plume backend server")
.after_help(
r#"
The plume command should be run inside the directory
containing the `.env` configuration file and `static` directory.
See https://docs.joinplu.me/installation/config
and https://docs.joinplu.me/installation/init for more info.
"#,
)
.get_matches();
let dbpool = init_pool().expect("main: database pool initialization error"); let dbpool = init_pool().expect("main: database pool initialization error");
if IMPORTED_MIGRATIONS if IMPORTED_MIGRATIONS
.is_pending(&dbpool.get().unwrap()) .is_pending(&dbpool.get().unwrap())