2024-01-11 00:22:57 +00:00
|
|
|
use crate::keeper_builder::*;
|
2024-02-05 23:01:38 +00:00
|
|
|
pub struct Cli<T: CliConfig> {
|
2024-01-06 16:19:59 +00:00
|
|
|
client: Client,
|
2024-02-05 23:01:38 +00:00
|
|
|
config: T,
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
impl<T: CliConfig> Cli<T> {
|
|
|
|
pub fn new(client: Client, config: T) -> Self {
|
|
|
|
Self { client, config }
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_command(cmd: CliCommand) -> clap::Command {
|
|
|
|
match cmd {
|
|
|
|
CliCommand::Enrol => Self::cli_enrol(),
|
|
|
|
CliCommand::GlobalJobs => Self::cli_global_jobs(),
|
|
|
|
CliCommand::Ping => Self::cli_ping(),
|
|
|
|
CliCommand::ReportFinish => Self::cli_report_finish(),
|
|
|
|
CliCommand::ReportOutput => Self::cli_report_output(),
|
|
|
|
CliCommand::ReportStart => Self::cli_report_start(),
|
|
|
|
}
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cli_enrol() -> clap::Command {
|
|
|
|
clap::Command::new("")
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("authorization")
|
|
|
|
.long("authorization")
|
|
|
|
.value_parser(clap::value_parser!(String))
|
2023-05-08 03:43:45 +00:00
|
|
|
.required(true)
|
2023-03-28 21:54:05 +00:00
|
|
|
.help("Authorization header (bearer token)"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("host")
|
|
|
|
.long("host")
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(String))
|
|
|
|
.required_unless_present("json-body"),
|
2023-03-28 21:54:05 +00:00
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("key")
|
|
|
|
.long("key")
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(String))
|
|
|
|
.required_unless_present("json-body"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body")
|
|
|
|
.long("json-body")
|
|
|
|
.value_name("JSON-FILE")
|
|
|
|
.required(false)
|
|
|
|
.value_parser(clap::value_parser!(std::path::PathBuf))
|
|
|
|
.help("Path to a file that contains the full json body."),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body-template")
|
|
|
|
.long("json-body-template")
|
|
|
|
.action(clap::ArgAction::SetTrue)
|
|
|
|
.help("XXX"),
|
2023-03-28 21:54:05 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cli_global_jobs() -> clap::Command {
|
|
|
|
clap::Command::new("").arg(
|
|
|
|
clap::Arg::new("authorization")
|
|
|
|
.long("authorization")
|
|
|
|
.value_parser(clap::value_parser!(String))
|
2023-05-08 03:43:45 +00:00
|
|
|
.required(true)
|
2023-03-28 21:54:05 +00:00
|
|
|
.help("Authorization header (bearer token)"),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cli_ping() -> clap::Command {
|
|
|
|
clap::Command::new("").arg(
|
|
|
|
clap::Arg::new("authorization")
|
|
|
|
.long("authorization")
|
|
|
|
.value_parser(clap::value_parser!(String))
|
2023-05-08 03:43:45 +00:00
|
|
|
.required(true)
|
2023-03-28 21:54:05 +00:00
|
|
|
.help("Authorization header (bearer token)"),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cli_report_finish() -> clap::Command {
|
|
|
|
clap::Command::new("")
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("authorization")
|
|
|
|
.long("authorization")
|
|
|
|
.value_parser(clap::value_parser!(String))
|
2023-05-08 03:43:45 +00:00
|
|
|
.required(true)
|
2023-03-28 21:54:05 +00:00
|
|
|
.help("Authorization header (bearer token)"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("duration-millis")
|
|
|
|
.long("duration-millis")
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(i32))
|
|
|
|
.required_unless_present("json-body"),
|
2023-03-28 21:54:05 +00:00
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("end-time")
|
|
|
|
.long("end-time")
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(chrono::DateTime<chrono::offset::Utc>))
|
|
|
|
.required_unless_present("json-body"),
|
2023-03-28 21:54:05 +00:00
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("exit-status")
|
|
|
|
.long("exit-status")
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(i32))
|
|
|
|
.required_unless_present("json-body"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body")
|
|
|
|
.long("json-body")
|
|
|
|
.value_name("JSON-FILE")
|
2023-03-28 21:54:05 +00:00
|
|
|
.required(true)
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(std::path::PathBuf))
|
|
|
|
.help("Path to a file that contains the full json body."),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body-template")
|
|
|
|
.long("json-body-template")
|
|
|
|
.action(clap::ArgAction::SetTrue)
|
|
|
|
.help("XXX"),
|
2023-03-28 21:54:05 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cli_report_output() -> clap::Command {
|
2023-05-08 03:43:45 +00:00
|
|
|
clap::Command::new("")
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("authorization")
|
|
|
|
.long("authorization")
|
|
|
|
.value_parser(clap::value_parser!(String))
|
|
|
|
.required(true)
|
|
|
|
.help("Authorization header (bearer token)"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body")
|
|
|
|
.long("json-body")
|
|
|
|
.value_name("JSON-FILE")
|
|
|
|
.required(true)
|
|
|
|
.value_parser(clap::value_parser!(std::path::PathBuf))
|
|
|
|
.help("Path to a file that contains the full json body."),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body-template")
|
|
|
|
.long("json-body-template")
|
|
|
|
.action(clap::ArgAction::SetTrue)
|
|
|
|
.help("XXX"),
|
|
|
|
)
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cli_report_start() -> clap::Command {
|
|
|
|
clap::Command::new("")
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("authorization")
|
|
|
|
.long("authorization")
|
|
|
|
.value_parser(clap::value_parser!(String))
|
2023-05-08 03:43:45 +00:00
|
|
|
.required(true)
|
2023-03-28 21:54:05 +00:00
|
|
|
.help("Authorization header (bearer token)"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("script")
|
|
|
|
.long("script")
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(String))
|
|
|
|
.required_unless_present("json-body"),
|
2023-03-28 21:54:05 +00:00
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("start-time")
|
|
|
|
.long("start-time")
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(chrono::DateTime<chrono::offset::Utc>))
|
|
|
|
.required_unless_present("json-body"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body")
|
|
|
|
.long("json-body")
|
|
|
|
.value_name("JSON-FILE")
|
2023-03-28 21:54:05 +00:00
|
|
|
.required(true)
|
2023-05-08 03:43:45 +00:00
|
|
|
.value_parser(clap::value_parser!(std::path::PathBuf))
|
|
|
|
.help("Path to a file that contains the full json body."),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
clap::Arg::new("json-body-template")
|
|
|
|
.long("json-body-template")
|
|
|
|
.action(clap::ArgAction::SetTrue)
|
|
|
|
.help("XXX"),
|
2023-03-28 21:54:05 +00:00
|
|
|
)
|
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) -> anyhow::Result<()> {
|
2023-03-29 23:50:41 +00:00
|
|
|
match cmd {
|
2024-02-05 23:01:38 +00:00
|
|
|
CliCommand::Enrol => self.execute_enrol(matches).await,
|
|
|
|
CliCommand::GlobalJobs => self.execute_global_jobs(matches).await,
|
|
|
|
CliCommand::Ping => self.execute_ping(matches).await,
|
|
|
|
CliCommand::ReportFinish => self.execute_report_finish(matches).await,
|
|
|
|
CliCommand::ReportOutput => self.execute_report_output(matches).await,
|
|
|
|
CliCommand::ReportStart => self.execute_report_start(matches).await,
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub async fn execute_enrol(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> {
|
2023-03-29 23:50:41 +00:00
|
|
|
let mut request = self.client.enrol();
|
2023-03-28 21:54:05 +00:00
|
|
|
if let Some(value) = matches.get_one::<String>("authorization") {
|
|
|
|
request = request.authorization(value.clone());
|
|
|
|
}
|
|
|
|
|
2023-03-29 23:50:41 +00:00
|
|
|
if let Some(value) = matches.get_one::<String>("host") {
|
|
|
|
request = request.body_map(|body| body.host(value.clone()))
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(value) = matches.get_one::<String>("key") {
|
|
|
|
request = request.body_map(|body| body.key(value.clone()))
|
|
|
|
}
|
|
|
|
|
2023-07-15 00:37:54 +00:00
|
|
|
if let Some(value) = matches.get_one::<std::path::PathBuf>("json-body") {
|
|
|
|
let body_txt = std::fs::read_to_string(value).unwrap();
|
|
|
|
let body_value = serde_json::from_str::<types::EnrolBody>(&body_txt).unwrap();
|
|
|
|
request = request.body(body_value);
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
self.config.execute_enrol(matches, &mut request)?;
|
2023-03-29 23:50:41 +00:00
|
|
|
let result = request.send().await;
|
|
|
|
match result {
|
|
|
|
Ok(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.success_no_item(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Ok(())
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
Err(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.error(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Err(anyhow::Error::new(r))
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub async fn execute_global_jobs(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> {
|
2023-03-29 23:50:41 +00:00
|
|
|
let mut request = self.client.global_jobs();
|
|
|
|
if let Some(value) = matches.get_one::<String>("authorization") {
|
|
|
|
request = request.authorization(value.clone());
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
self.config.execute_global_jobs(matches, &mut request)?;
|
2023-03-28 21:54:05 +00:00
|
|
|
let result = request.send().await;
|
|
|
|
match result {
|
|
|
|
Ok(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.success_item(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Ok(())
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
|
|
|
Err(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.error(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Err(anyhow::Error::new(r))
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub async fn execute_ping(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> {
|
2023-03-29 23:50:41 +00:00
|
|
|
let mut request = self.client.ping();
|
|
|
|
if let Some(value) = matches.get_one::<String>("authorization") {
|
|
|
|
request = request.authorization(value.clone());
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
self.config.execute_ping(matches, &mut request)?;
|
2023-03-29 23:50:41 +00:00
|
|
|
let result = request.send().await;
|
|
|
|
match result {
|
|
|
|
Ok(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.success_item(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Ok(())
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
|
|
|
Err(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.error(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Err(anyhow::Error::new(r))
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub async fn execute_report_finish(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> {
|
2023-03-29 23:50:41 +00:00
|
|
|
let mut request = self.client.report_finish();
|
|
|
|
if let Some(value) = matches.get_one::<String>("authorization") {
|
|
|
|
request = request.authorization(value.clone());
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(value) = matches.get_one::<i32>("duration-millis") {
|
|
|
|
request = request.body_map(|body| body.duration_millis(value.clone()))
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(value) = matches.get_one::<chrono::DateTime<chrono::offset::Utc>>("end-time") {
|
|
|
|
request = request.body_map(|body| body.end_time(value.clone()))
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(value) = matches.get_one::<i32>("exit-status") {
|
|
|
|
request = request.body_map(|body| body.exit_status(value.clone()))
|
|
|
|
}
|
|
|
|
|
2023-07-15 00:37:54 +00:00
|
|
|
if let Some(value) = matches.get_one::<std::path::PathBuf>("json-body") {
|
|
|
|
let body_txt = std::fs::read_to_string(value).unwrap();
|
|
|
|
let body_value = serde_json::from_str::<types::ReportFinishBody>(&body_txt).unwrap();
|
|
|
|
request = request.body(body_value);
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
self.config.execute_report_finish(matches, &mut request)?;
|
2023-03-29 23:50:41 +00:00
|
|
|
let result = request.send().await;
|
|
|
|
match result {
|
|
|
|
Ok(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.success_item(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Ok(())
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
Err(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.error(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Err(anyhow::Error::new(r))
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub async fn execute_report_output(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> {
|
2023-03-29 23:50:41 +00:00
|
|
|
let mut request = self.client.report_output();
|
2023-07-15 00:37:54 +00:00
|
|
|
if let Some(value) = matches.get_one::<String>("authorization") {
|
|
|
|
request = request.authorization(value.clone());
|
|
|
|
}
|
|
|
|
|
2023-05-08 03:43:45 +00:00
|
|
|
if let Some(value) = matches.get_one::<std::path::PathBuf>("json-body") {
|
|
|
|
let body_txt = std::fs::read_to_string(value).unwrap();
|
|
|
|
let body_value = serde_json::from_str::<types::ReportOutputBody>(&body_txt).unwrap();
|
|
|
|
request = request.body(body_value);
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
self.config.execute_report_output(matches, &mut request)?;
|
2023-03-29 23:50:41 +00:00
|
|
|
let result = request.send().await;
|
|
|
|
match result {
|
|
|
|
Ok(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.success_item(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Ok(())
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
Err(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.error(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Err(anyhow::Error::new(r))
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub async fn execute_report_start(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> {
|
2023-03-29 23:50:41 +00:00
|
|
|
let mut request = self.client.report_start();
|
|
|
|
if let Some(value) = matches.get_one::<String>("authorization") {
|
|
|
|
request = request.authorization(value.clone());
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(value) = matches.get_one::<String>("script") {
|
|
|
|
request = request.body_map(|body| body.script(value.clone()))
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(value) = matches.get_one::<chrono::DateTime<chrono::offset::Utc>>("start-time")
|
|
|
|
{
|
|
|
|
request = request.body_map(|body| body.start_time(value.clone()))
|
|
|
|
}
|
|
|
|
|
2023-07-15 00:37:54 +00:00
|
|
|
if let Some(value) = matches.get_one::<std::path::PathBuf>("json-body") {
|
|
|
|
let body_txt = std::fs::read_to_string(value).unwrap();
|
|
|
|
let body_value = serde_json::from_str::<types::ReportStartBody>(&body_txt).unwrap();
|
|
|
|
request = request.body(body_value);
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
self.config.execute_report_start(matches, &mut request)?;
|
2023-03-29 23:50:41 +00:00
|
|
|
let result = request.send().await;
|
|
|
|
match result {
|
|
|
|
Ok(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.success_item(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Ok(())
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
Err(r) => {
|
2024-05-15 18:04:45 +00:00
|
|
|
self.config.error(&r);
|
2024-02-05 23:01:38 +00:00
|
|
|
Err(anyhow::Error::new(r))
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
2023-03-29 23:50:41 +00:00
|
|
|
}
|
2023-03-28 21:54:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-05 23:01:38 +00:00
|
|
|
pub trait CliConfig {
|
2024-05-15 18:04:45 +00:00
|
|
|
fn success_item<T>(&self, value: &ResponseValue<T>)
|
2024-02-05 23:01:38 +00:00
|
|
|
where
|
|
|
|
T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug;
|
2024-05-15 18:04:45 +00:00
|
|
|
fn success_no_item(&self, value: &ResponseValue<()>);
|
|
|
|
fn error<T>(&self, value: &Error<T>)
|
2024-02-05 23:01:38 +00:00
|
|
|
where
|
|
|
|
T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug;
|
|
|
|
fn list_start<T>(&self)
|
|
|
|
where
|
|
|
|
T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug;
|
|
|
|
fn list_item<T>(&self, value: &T)
|
|
|
|
where
|
|
|
|
T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug;
|
|
|
|
fn list_end_success<T>(&self)
|
|
|
|
where
|
|
|
|
T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug;
|
|
|
|
fn list_end_error<T>(&self, value: &Error<T>)
|
|
|
|
where
|
|
|
|
T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug;
|
2023-03-28 21:54:05 +00:00
|
|
|
fn execute_enrol(
|
|
|
|
&self,
|
|
|
|
matches: &clap::ArgMatches,
|
2023-03-29 23:50:41 +00:00
|
|
|
request: &mut builder::Enrol,
|
2024-02-05 23:01:38 +00:00
|
|
|
) -> anyhow::Result<()> {
|
2023-03-28 21:54:05 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn execute_global_jobs(
|
|
|
|
&self,
|
|
|
|
matches: &clap::ArgMatches,
|
2023-03-29 23:50:41 +00:00
|
|
|
request: &mut builder::GlobalJobs,
|
2024-02-05 23:01:38 +00:00
|
|
|
) -> anyhow::Result<()> {
|
2023-03-28 21:54:05 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn execute_ping(
|
|
|
|
&self,
|
|
|
|
matches: &clap::ArgMatches,
|
2023-03-29 23:50:41 +00:00
|
|
|
request: &mut builder::Ping,
|
2024-02-05 23:01:38 +00:00
|
|
|
) -> anyhow::Result<()> {
|
2023-03-28 21:54:05 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn execute_report_finish(
|
|
|
|
&self,
|
|
|
|
matches: &clap::ArgMatches,
|
2023-03-29 23:50:41 +00:00
|
|
|
request: &mut builder::ReportFinish,
|
2024-02-05 23:01:38 +00:00
|
|
|
) -> anyhow::Result<()> {
|
2023-03-28 21:54:05 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn execute_report_output(
|
|
|
|
&self,
|
|
|
|
matches: &clap::ArgMatches,
|
2023-03-29 23:50:41 +00:00
|
|
|
request: &mut builder::ReportOutput,
|
2024-02-05 23:01:38 +00:00
|
|
|
) -> anyhow::Result<()> {
|
2023-03-28 21:54:05 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn execute_report_start(
|
|
|
|
&self,
|
|
|
|
matches: &clap::ArgMatches,
|
2023-03-29 23:50:41 +00:00
|
|
|
request: &mut builder::ReportStart,
|
2024-02-05 23:01:38 +00:00
|
|
|
) -> anyhow::Result<()> {
|
2023-03-28 21:54:05 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug)]
|
|
|
|
pub enum CliCommand {
|
|
|
|
Enrol,
|
|
|
|
GlobalJobs,
|
|
|
|
Ping,
|
|
|
|
ReportFinish,
|
|
|
|
ReportOutput,
|
|
|
|
ReportStart,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CliCommand {
|
|
|
|
pub fn iter() -> impl Iterator<Item = CliCommand> {
|
|
|
|
vec![
|
|
|
|
CliCommand::Enrol,
|
|
|
|
CliCommand::GlobalJobs,
|
|
|
|
CliCommand::Ping,
|
|
|
|
CliCommand::ReportFinish,
|
|
|
|
CliCommand::ReportOutput,
|
|
|
|
CliCommand::ReportStart,
|
|
|
|
]
|
|
|
|
.into_iter()
|
|
|
|
}
|
|
|
|
}
|