Main mastodon logic, reorganization of the global app to reflect the fact that a subcommand is possible

This commit is contained in:
VC
2020-03-01 13:44:32 +01:00
parent 3641bf61bb
commit 18655f1e68
2 changed files with 122 additions and 31 deletions

View File

@@ -1,7 +1,38 @@
// self
use scootaloo::*;
// clap
use clap::{App, Arg, SubCommand};
fn main() {
let config = Config::new();
let matches = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.about("A Twitter to Mastodon bot")
.arg(Arg::with_name("config")
.short("c")
.long("config")
.value_name("CONFIG_FILE")
.help("TOML config file for scootaloo (default /usr/local/etc/scootaloo.toml)")
.takes_value(true)
.display_order(1))
.subcommand(SubCommand::with_name("register")
.version(env!("CARGO_PKG_VERSION"))
.about("Command to register to a Mastodon Instance")
.arg(Arg::with_name("host")
.short("h")
.long("host")
.value_name("HOST")
.help("Base URL of the Mastodon instance to register to (no default)")
.takes_value(true)
.required(true)
.display_order(1)))
.get_matches();
if let Some(matches) = matches.subcommand_matches("register") {
register(matches.value_of("host").unwrap());
return;
}
let config = parse_toml(matches.value_of("config").unwrap());
run(config);
}