diff --git a/sfsmcctl/Cargo.toml b/sfsmcctl/Cargo.toml index f798d27..2ff1c80 100644 --- a/sfsmcctl/Cargo.toml +++ b/sfsmcctl/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Elias Schriefer"] edition = "2018" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "2.33", features = ["wrap_help", "color"] } toml = "0.5" tokio = { version = "0.2", features = ["full"] } async-minecraft-ping = "0.2" diff --git a/sfsmcctl/src/main.rs b/sfsmcctl/src/main.rs index d80d1a8..ec00137 100644 --- a/sfsmcctl/src/main.rs +++ b/sfsmcctl/src/main.rs @@ -4,6 +4,7 @@ use dbus::{ Error }; use std::sync::Arc; +use clap::clap_app; const DBUS_NAME: &'static str = "org.ddnss.sfs.mc"; @@ -109,6 +110,43 @@ async fn main() -> Result<(), Box> { env_logger::init(); // TODO: use clap + let clapped = clap_app!((clap::crate_name!()) => + (version: clap::crate_version!()) + (author: &*clap::crate_authors!().split(":").collect::>().join(", ")) + (about: clap::crate_description!()) + (@setting DeriveDisplayOrder) + (@setting SubcommandRequiredElseHelp) + (@setting GlobalVersion) + (@subcommand start => + (about: "Start sfsmcd") + ) + (@subcommand stop => + (about: "Stop sfsmcd") + ) + (@subcommand restart => + (about: "Restart sfsmcd") + ) + (subcommand: clap::SubCommand::with_name("is-running") + .about("Get whether sfsmcd is running") + ) + (@subcommand minecraft => + (about: "The minecraft server service") + (@setting DeriveDisplayOrder) + (@setting SubcommandRequiredElseHelp) + (@subcommand start => + (about: "Start minecraft server") + ) + (@subcommand stop => + (about: "Stop minecraft server") + ) + (@subcommand restart => + (about: "Restart minecraft server") + ) + (subcommand: clap::SubCommand::with_name("is-running") + .about("Get whether minecraft server is running") + ) + ) + ).get_matches(); // Connect with D-Bus let (resource, c) = dbus_tokio::connection::new_system_sync()?;