mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-21 09:31:19 +02:00
Main mastodon logic, reorganization of the global app to reflect the fact that a subcommand is possible
This commit is contained in:
33
src/main.rs
33
src/main.rs
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user