diff --git a/Cargo.lock b/Cargo.lock index a48b32d..5d47fd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,55 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -42,6 +91,7 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" name = "btcmap-cli" version = "0.1.0" dependencies = [ + "clap", "colored_json", "dirs", "rusqlite", @@ -76,6 +126,52 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "colored_json" version = "5.0.0" @@ -209,6 +305,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hoot" version = "0.2.3" @@ -249,6 +351,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itoa" version = "1.0.11" @@ -618,6 +726,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.6.1" @@ -739,6 +853,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index f50242e..5d33008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,4 @@ colored_json = "5.0.0" rusqlite = { version = "0.32.1", features = ["bundled"] } dirs = "5.0.1" serde_json = "1.0.128" +clap = { version = "4.5.20", features = ["derive"] } diff --git a/src/command/admin.rs b/src/command/admin.rs new file mode 100644 index 0000000..77e048f --- /dev/null +++ b/src/command/admin.rs @@ -0,0 +1,42 @@ +use crate::{rpc, Result}; +use clap::Args; +use serde_json::json; + +#[derive(Args)] +pub struct AddAdminArgs { + pub new_admin_name: String, + pub new_admin_password: String, +} + +pub fn add_admin(args: &AddAdminArgs) -> Result<()> { + rpc::call( + "add_admin", + json!({"new_admin_name": args.new_admin_name, "new_admin_password": args.new_admin_password}), + ) +} + +#[derive(Args)] +pub struct AddAllowedActionArgs { + pub admin_name: String, + pub action: String, +} + +pub fn add_allowed_action(args: &AddAllowedActionArgs) -> Result<()> { + rpc::call( + "add_allowed_action", + json!({"admin_name": args.admin_name, "action": args.action}), + ) +} + +#[derive(Args)] +pub struct RemoveAllowedActionArgs { + pub admin_name: String, + pub action: String, +} + +pub fn remove_allowed_action(args: &RemoveAllowedActionArgs) -> Result<()> { + rpc::call( + "remove_allowed_action", + json!({"admin_name": args.admin_name, "action": args.action}), + ) +} diff --git a/src/command/area.rs b/src/command/area.rs new file mode 100644 index 0000000..ab231ac --- /dev/null +++ b/src/command/area.rs @@ -0,0 +1,63 @@ +use crate::{rpc, Result}; +use clap::Args; +use serde_json::json; + +#[derive(Args)] +pub struct GetAreaArgs { + pub id: String, +} + +pub fn get_area(args: &GetAreaArgs) -> Result<()> { + rpc::call("get_area", json!({"id": args.id})) +} + +#[derive(Args)] +pub struct SetAreaTagArgs { + pub id: String, + pub name: String, + pub value: serde_json::Value, +} + +pub fn set_area_tag(args: &SetAreaTagArgs) -> Result<()> { + rpc::call( + "set_area_tag", + json!({"id": args.id,"name": args.name, "value": args.value}), + ) +} + +#[derive(Args)] +pub struct RemoveAreaTagArgs { + pub id: String, + pub tag: String, +} + +pub fn remove_area_tag(args: &RemoveAreaTagArgs) -> Result<()> { + rpc::call("remove_area_tag", json!({"id": args.id,"tag": args.tag})) +} + +#[derive(Args)] +pub struct SetAreaIconArgs { + pub id: String, + pub icon_base64: String, + pub icon_ext: String, +} + +pub fn set_area_icon(args: &SetAreaIconArgs) -> Result<()> { + rpc::call( + "set_area_icon", + json!({"id": args.id,"icon_base64": args.icon_base64,"icon_ext": args.icon_ext}), + ) +} + +#[derive(Args)] +pub struct GenerateAreasElementsMappingArgs { + pub from_element_id: i64, + pub to_element_id: i64, +} + +pub fn generate_areas_elements_mapping(args: &GenerateAreasElementsMappingArgs) -> Result<()> { + rpc::call( + "generate_areas_elements_mapping", + json!({"from_element_id": args.from_element_id,"to_element_id": args.to_element_id}), + ) +} diff --git a/src/command/common.rs b/src/command/common.rs new file mode 100644 index 0000000..3d22af8 --- /dev/null +++ b/src/command/common.rs @@ -0,0 +1,12 @@ +use crate::{rpc, Result}; +use clap::Args; +use serde_json::json; + +#[derive(Args)] +pub struct SearchArgs { + pub query: String, +} + +pub fn search(args: &SearchArgs) -> Result<()> { + rpc::call("search", json!({"query": args.query})) +} diff --git a/src/command/element.rs b/src/command/element.rs new file mode 100644 index 0000000..b5fc859 --- /dev/null +++ b/src/command/element.rs @@ -0,0 +1,106 @@ +use crate::{rpc, Result}; +use clap::Args; +use serde_json::json; + +#[derive(Args)] +pub struct GetElementArgs { + pub id: String, +} + +pub fn get_element(args: &GetElementArgs) -> Result<()> { + rpc::call("get_element", json!({"id": args.id})) +} + +#[derive(Args)] +pub struct SetElementTagArgs { + pub id: String, + pub name: String, + pub value: serde_json::Value, +} + +pub fn set_element_tag(args: &SetElementTagArgs) -> Result<()> { + rpc::call( + "set_element_tag", + json!({"id": args.id,"name": args.name, "value": args.value}), + ) +} + +#[derive(Args)] +pub struct RemoveElementTagArgs { + pub id: String, + pub tag: String, +} + +pub fn remove_element_tag(args: &RemoveElementTagArgs) -> Result<()> { + rpc::call("remove_element_tag", json!({"id": args.id,"tag": args.tag})) +} + +#[derive(Args)] +pub struct AddElementCommentArgs { + pub id: String, + pub comment: String, +} + +pub fn add_element_comment(args: &AddElementCommentArgs) -> Result<()> { + rpc::call( + "add_element_comment", + json!({"id": args.id,"comment": args.comment}), + ) +} + +#[derive(Args)] +pub struct BoostElementArgs { + pub id: String, + pub days: i64, +} + +pub fn boost_element(args: &BoostElementArgs) -> Result<()> { + rpc::call("boost_element", json!({"id": args.id,"days": args.days})) +} + +#[derive(Args)] +pub struct GetBoostsArgs {} + +pub fn get_boosts(_: &GetBoostsArgs) -> Result<()> { + rpc::call("get_boosts", json!({})) +} + +#[derive(Args)] +pub struct SyncElementsArgs {} + +pub fn sync_elements(_: &SyncElementsArgs) -> Result<()> { + rpc::call("sync_elements", json!({})) +} + +#[derive(Args)] +pub struct GenerateElementIconsArgs { + pub from_element_id: i64, + pub to_element_id: i64, +} + +pub fn generate_element_icons(args: &GenerateElementIconsArgs) -> Result<()> { + rpc::call( + "generate_element_icons", + json!({"from_element_id": args.from_element_id,"to_element_id": args.to_element_id}), + ) +} + +#[derive(Args)] +pub struct GenerateElementCategoriesArgs { + pub from_element_id: i64, + pub to_element_id: i64, +} + +pub fn generate_element_categories(args: &GenerateElementCategoriesArgs) -> Result<()> { + rpc::call( + "generate_element_categories", + json!({"from_element_id": args.from_element_id,"to_element_id": args.to_element_id}), + ) +} + +#[derive(Args)] +pub struct GenerateElementIssuesArgs {} + +pub fn generate_element_issues(_: &GenerateElementIssuesArgs) -> Result<()> { + rpc::call("generate_element_issues", json!({})) +} diff --git a/src/command/mod.rs b/src/command/mod.rs new file mode 100644 index 0000000..8d3aec4 --- /dev/null +++ b/src/command/mod.rs @@ -0,0 +1,7 @@ +pub mod admin; +pub mod area; +pub mod common; +pub mod element; +pub mod report; +pub mod setup; +pub mod user; diff --git a/src/command/report.rs b/src/command/report.rs new file mode 100644 index 0000000..e3481ef --- /dev/null +++ b/src/command/report.rs @@ -0,0 +1,49 @@ +use crate::{rpc, Result}; +use clap::Args; +use serde_json::json; + +#[derive(Args)] +pub struct GenerateReportsArgs {} + +pub fn generate_reports(_: &GenerateReportsArgs) -> Result<()> { + rpc::call("generate_reports", json!({})) +} + +#[derive(Args)] +pub struct GetTrendingCountriesArgs { + pub period_start: String, + pub period_end: String, +} + +pub fn get_trending_countries(args: &GetTrendingCountriesArgs) -> Result<()> { + rpc::call( + "get_trending_countries", + json!({"period_start": args.period_start, "period_end": args.period_end}), + ) +} + +#[derive(Args)] +pub struct GetTrendingCommunitiesArgs { + pub period_start: String, + pub period_end: String, +} + +pub fn get_trending_communities(args: &GetTrendingCommunitiesArgs) -> Result<()> { + rpc::call( + "get_trending_communities", + json!({"period_start": args.period_start, "period_end": args.period_end}), + ) +} + +#[derive(Args)] +pub struct GetMostCommentedCountriesArgs { + pub period_start: String, + pub period_end: String, +} + +pub fn get_most_commented_countries(args: &GetMostCommentedCountriesArgs) -> Result<()> { + rpc::call( + "get_most_commented_countries", + json!({"period_start": args.period_start, "period_end": args.period_end}), + ) +} diff --git a/src/command/setup.rs b/src/command/setup.rs new file mode 100644 index 0000000..465e432 --- /dev/null +++ b/src/command/setup.rs @@ -0,0 +1,27 @@ +use crate::{settings, Result}; +use clap::Args; + +#[derive(Args)] +pub struct SetServerArgs { + pub url: String, +} + +pub fn set_server(args: &SetServerArgs) -> Result<()> { + let url = match args.url.as_str() { + "prod" => "https://api.btcmap.org/rpc", + "dev" => "http://127.0.0.1:8000/rpc", + _ => &args.url, + }; + settings::put_str("api_url", &url)?; + Ok(()) +} + +#[derive(Args)] +pub struct LoginArgs { + pub password: String, +} + +pub fn login(args: &LoginArgs) -> Result<()> { + settings::put_str("password", &args.password)?; + Ok(()) +} diff --git a/src/command/user.rs b/src/command/user.rs new file mode 100644 index 0000000..fb6b343 --- /dev/null +++ b/src/command/user.rs @@ -0,0 +1,16 @@ +use crate::{rpc, Result}; +use clap::Args; +use serde_json::json; + +#[derive(Args)] +pub struct GetUserActivityArgs { + pub id: String, + pub limit: i64, +} + +pub fn get_user_activity(args: &GetUserActivityArgs) -> Result<()> { + rpc::call( + "get_user_activity", + json!({"id": args.id, "limit": args.limit}), + ) +} diff --git a/src/main.rs b/src/main.rs index ab8397a..d6fe7f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,198 +1,116 @@ -use serde_json::json; -use std::env; -use std::env::Args; use std::error::Error; mod rpc; mod settings; +use clap::{Parser, Subcommand}; +use command::{ + area, + element::{ + self, GenerateElementCategoriesArgs, GenerateElementIconsArgs, GenerateElementIssuesArgs, + }, +}; +mod command; -const UNAUTHORIZED_ACTIONS: [&str; 2] = ["login", "help"]; - -type Result = std::result::Result>; +#[derive(Parser)] +#[command(version, about, long_about = None)] +struct Cli { + #[command(subcommand)] + command: Option, +} -fn get_arg(args: &mut Args) -> Result { - Ok(args - .next() - .ok_or("You need to provide one more command line argument")?) +#[derive(Subcommand)] +enum Commands { + // Setup + SetServer(command::setup::SetServerArgs), + Login(command::setup::LoginArgs), + // Admin + AddAdmin(command::admin::AddAdminArgs), + AddAllowedAction(command::admin::AddAllowedActionArgs), + RemoveAllowedAction(command::admin::RemoveAllowedActionArgs), + // Common + Search(command::common::SearchArgs), + // Element + GetElement(command::element::GetElementArgs), + SetElementTag(command::element::SetElementTagArgs), + RemoveElementTag(command::element::RemoveElementTagArgs), + AddElementComment(command::element::AddElementCommentArgs), + BoostElement(command::element::BoostElementArgs), + GetBoosts(command::element::GetBoostsArgs), + SyncElements(command::element::SyncElementsArgs), + GenerateElementIcons(GenerateElementIconsArgs), + GenerateElementCategories(GenerateElementCategoriesArgs), + GenerateElementIssues(GenerateElementIssuesArgs), + // Area + GetArea(command::area::GetAreaArgs), + SetAreaTag(command::area::SetAreaTagArgs), + RemoveAreaTag(command::area::RemoveAreaTagArgs), + SetAreaIcon(command::area::SetAreaIconArgs), + GenerateAreasElementsMapping(command::area::GenerateAreasElementsMappingArgs), + // User + GetUserActivity(command::user::GetUserActivityArgs), + // Report + GenerateReports(command::report::GenerateReportsArgs), + GetTrendingCountries(command::report::GetTrendingCountriesArgs), + GetTrendingCommunities(command::report::GetTrendingCommunitiesArgs), + GetMostCommentedCountries(command::report::GetMostCommentedCountriesArgs), } +type Result = std::result::Result>; + fn main() -> Result<()> { - let mut args = env::args(); - drop(args.next()); - let action = args - .next() - .ok_or("you need to provide an action, run btcmap-cli help to see all supported actions")?; - let action = action.replace("-", "_"); - let action = action.as_str(); - if settings::get_str("password")?.is_empty() && !UNAUTHORIZED_ACTIONS.contains(&action) { + let cli = Cli::parse(); + + if let Some(Commands::SetServer(args)) = &cli.command { + return command::setup::set_server(args); + } + + if let Some(Commands::Login(args)) = &cli.command { + return command::setup::login(args); + } + + if settings::get_str("password")?.is_empty() { Err("you need to login first, run btcmap-cli login ")?; } - match action { - "help" => help(), - "set_server" => { - let url = get_arg(&mut args)?; - let url = url.as_str(); - let url = match url { - "prod" => "https://api.btcmap.org/rpc", - "dev" => "http://127.0.0.1:8000/rpc", - _ => url, - }; - settings::put_str("api_url", &url)?; - println!("saved {url} as a server for all future actions"); - } - "login" => { - let token = get_arg(&mut args)?; - settings::put_str("password", &token)?; - println!("saved {token} as a password for all future actions"); - } - "get_element" => { - let id = get_arg(&mut args)?.replace("=", ":"); - rpc::call(action, json!({"id":id}))?; - } - "boost_element" => { - let id = get_arg(&mut args)?.replace("=", ":"); - let days = get_arg(&mut args)?.parse::()?; - rpc::call(action, json!({"id":id,"days":days}))?; - } - "generate_reports" => rpc::call(action, json!({}))?, - "generate_element_icons" => { - let from_element_id = get_arg(&mut args)?.parse::()?; - let to_element_id = get_arg(&mut args)?.parse::()?; - rpc::call( - action, - json!({"from_element_id":from_element_id,"to_element_id":to_element_id}), - )?; - } - "generate_element_categories" => { - let from_element_id = get_arg(&mut args)?.parse::()?; - let to_element_id = get_arg(&mut args)?.parse::()?; - rpc::call( - action, - json!({"from_element_id":from_element_id,"to_element_id":to_element_id}), - )?; - } - "add_element_comment" => { - let id = get_arg(&mut args)?.replace("=", ":"); - let comment = get_arg(&mut args)?; - rpc::call(action, json!({"id":id,"comment":comment}))?; - } - "get_area" => { - let id = get_arg(&mut args)?; - rpc::call(action, json!({"id":id}))?; - } - "set_area_tag" => { - let id = get_arg(&mut args)?; - let name = get_arg(&mut args)?; - let value = get_arg(&mut args)?; - rpc::call(action, json!({"id":id,"name":name,"value":value}))?; - } - "remove_area_tag" => { - let id = get_arg(&mut args)?; - let tag = get_arg(&mut args)?; - rpc::call(action, json!({"id":id,"tag":tag}))?; - } - "get_trending_countries" => { - let period_start = get_arg(&mut args)?; - let period_end = get_arg(&mut args)?; - rpc::call( - action, - json!({"period_start":period_start,"period_end":period_end}), - )?; - } - "get_trending_communities" => { - let period_start = get_arg(&mut args)?; - let period_end = get_arg(&mut args)?; - rpc::call( - action, - json!({"period_start":period_start,"period_end":period_end}), - )?; - } - "generate_element_issues" => rpc::call(action, json!({}))?, - "sync_elements" => rpc::call(action, json!({}))?, - "get_most_commented_countries" => { - let period_start = get_arg(&mut args)?; - let period_end = get_arg(&mut args)?; - rpc::call( - action, - json!({"period_start":period_start,"period_end":period_end}), - )?; - } - "generate_areas_elements_mapping" => { - let from_element_id = get_arg(&mut args)?.parse::()?; - let to_element_id = get_arg(&mut args)?.parse::()?; - rpc::call( - action, - json!({"from_element_id":from_element_id,"to_element_id":to_element_id}), - )?; - } - "add_allowed_action" => { - let admin_name = get_arg(&mut args)?; - let allowed_action = get_arg(&mut args)?; - rpc::call( - action, - json!({"admin_name":admin_name,"action":allowed_action}), - )?; - } - "remove_allowed_action" => { - let admin_name = get_arg(&mut args)?; - let allowed_action = get_arg(&mut args)?; - rpc::call( - action, - json!({"admin_name":admin_name,"action":allowed_action}), - )?; - } - "get_user_activity" => { - let id = get_arg(&mut args)?; - let limit = get_arg(&mut args) - .unwrap_or(100000.to_string()) - .parse::()?; - rpc::call(action, json!({"id":id,"limit":limit}))?; - } - "search" => { - let query = get_arg(&mut args)?; - rpc::call(action, json!({"query":query}))?; - } - "set_area_icon" => { - let id = get_arg(&mut args)?; - let icon_base64 = get_arg(&mut args)?; - let icon_ext = get_arg(&mut args)?; - rpc::call( - action, - json!({"id":id,"icon_base64":icon_base64,"icon_ext":icon_ext}), - )?; - } - "get-boosts" => rpc::call(action, json!({}))?, - _ => { - eprintln!("action {action} does not exist, check btcmap-cli help to see all available actions") + + let command = match &cli.command { + Some(command) => command, + None => return Ok(()), + }; + + match command { + // Setup + Commands::SetServer(_) => Err("supposed to be unreachable".into()), + Commands::Login(_) => Err("supposed to be unreachable".into()), + // Admin + Commands::AddAdmin(args) => command::admin::add_admin(args), + Commands::AddAllowedAction(args) => command::admin::add_allowed_action(args), + Commands::RemoveAllowedAction(args) => command::admin::remove_allowed_action(args), + // Common + Commands::Search(args) => command::common::search(args), + // Element + Commands::GetElement(args) => element::get_element(args), + Commands::SetElementTag(args) => element::set_element_tag(args), + Commands::RemoveElementTag(args) => element::remove_element_tag(args), + Commands::AddElementComment(args) => element::add_element_comment(args), + Commands::BoostElement(args) => element::boost_element(args), + Commands::GetBoosts(args) => element::get_boosts(args), + Commands::SyncElements(args) => element::sync_elements(args), + Commands::GenerateElementIcons(args) => element::generate_element_icons(args), + Commands::GenerateElementCategories(args) => element::generate_element_categories(args), + Commands::GenerateElementIssues(args) => element::generate_element_issues(args), + // Area + Commands::GetArea(args) => area::get_area(args), + Commands::SetAreaTag(args) => area::set_area_tag(args), + Commands::RemoveAreaTag(args) => area::remove_area_tag(args), + Commands::SetAreaIcon(args) => area::set_area_icon(args), + Commands::GenerateAreasElementsMapping(args) => area::generate_areas_elements_mapping(args), + // User + Commands::GetUserActivity(args) => command::user::get_user_activity(args), + // Report + Commands::GenerateReports(args) => command::report::generate_reports(args), + Commands::GetTrendingCountries(args) => command::report::get_trending_countries(args), + Commands::GetTrendingCommunities(args) => command::report::get_trending_communities(args), + Commands::GetMostCommentedCountries(args) => { + command::report::get_most_commented_countries(args) } } - Ok(()) -} - -fn help() { - println!("add-admin "); - println!("add-area "); - println!("add-element-comment "); - println!("boost-element "); - println!("generate-areas-elements-mapping "); - println!("generate-element-categories "); - println!("generate-element-icons "); - println!("generate-element-issues"); - println!("generate-reports"); - println!("get-area "); - println!("get-element "); - println!("get-most-commented-countries "); - println!("get-trending-communities "); - println!("get-trending-countries "); - println!("remove-area "); - println!("remove-area-tag "); - println!("remove-element-tag "); - println!("set-area-tag "); - println!("set-element-tag "); - println!("sync-elements"); - println!("add-allowed-action "); - println!("remove-allowed-action "); - println!("get-user-activity [limit:int]"); - println!("search "); - println!("set-area-icon "); - println!("get-boosts"); }