Add basic clap functionality
This commit is contained in:
parent
cc4d0f08a4
commit
ef655b1aae
@ -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"
|
||||
|
@ -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<dyn std::error::Error>> {
|
||||
env_logger::init();
|
||||
|
||||
// TODO: use clap
|
||||
let clapped = clap_app!((clap::crate_name!()) =>
|
||||
(version: clap::crate_version!())
|
||||
(author: &*clap::crate_authors!().split(":").collect::<Vec<_>>().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()?;
|
||||
|
Loading…
Reference in New Issue
Block a user