use domo::public::Client;
use structopt::StructOpt;
mod account;
mod activity;
mod buzz;
mod dataset;
mod group;
mod page;
mod stream;
mod user;
mod util;
mod wh;
mod workflow;
#[derive(StructOpt, Debug)]
#[structopt(name = "domo")]
struct DomoApp {
#[structopt(long = "editor", default_value = "vim", env = "DOMO_EDITOR")]
editor: String,
#[structopt(
long = "host",
default_value = "https://api.domo.com",
env = "DOMO_API_HOST"
)]
host: String,
#[structopt(long = "clientid", env = "DOMO_API_CLIENT_ID")]
client_id: String,
#[structopt(long = "clientsecret", env = "DOMO_API_CLIENT_SECRET")]
client_secret: String,
#[structopt(short = "t", long = "template")]
template: Option<String>,
#[structopt(subcommand)]
command: DomoCommand,
}
#[derive(StructOpt, Debug)]
enum DomoCommand {
#[structopt(name = "account")]
Account {
#[structopt(subcommand)]
command: account::AccountCommand,
},
#[structopt(name = "activity")]
Activity {
#[structopt(subcommand)]
command: activity::ActivityCommand,
},
#[structopt(name = "buzz")]
Buzz {
#[structopt(subcommand)]
command: buzz::BuzzCommand,
},
#[structopt(name = "dataset")]
DataSet {
#[structopt(subcommand)]
command: dataset::DataSetCommand,
},
#[structopt(name = "group")]
Group {
#[structopt(subcommand)]
command: group::GroupCommand,
},
#[structopt(name = "page")]
Page {
#[structopt(subcommand)]
command: page::PageCommand,
},
#[structopt(name = "stream")]
Stream {
#[structopt(subcommand)]
command: stream::StreamCommand,
},
#[structopt(name = "user")]
User {
#[structopt(subcommand)]
command: user::UserCommand,
},
#[structopt(name = "webhook")]
Webhook {
#[structopt(subcommand)]
command: wh::WebhookCommand,
},
#[structopt(name = "workflow")]
Workflow {
#[structopt(subcommand)]
command: workflow::WorkflowCommand,
},
}
#[async_std::main]
async fn main() {
let app = DomoApp::from_args();
let dc = Client::new(&app.host, &app.client_id, &app.client_secret);
match app.command {
DomoCommand::Account { command } => {
account::execute(dc, &app.editor, app.template, command).await
}
DomoCommand::Activity { command } => activity::execute(dc, app.template, command).await,
DomoCommand::Buzz { command } => {
buzz::execute(dc, &app.editor, app.template, command).await
}
DomoCommand::DataSet { command } => {
dataset::execute(dc, &app.editor, app.template, command).await
}
DomoCommand::Group { command } => {
group::execute(dc, &app.editor, app.template, command).await
}
DomoCommand::Page { command } => {
page::execute(dc, &app.editor, app.template, command).await
}
DomoCommand::Stream { command } => {
stream::execute(dc, &app.editor, app.template, command).await
}
DomoCommand::User { command } => {
user::execute(dc, &app.editor, app.template, command).await
}
DomoCommand::Webhook { command } => wh::execute(&app.editor, command).await,
DomoCommand::Workflow { command } => {
workflow::execute(dc, &app.editor, app.template, command).await
}
}
}