use clap::{Args, Subcommand};
pub use accept::AcceptCommand;
pub use create::CreateCommand;
pub use list::ListCommand;
pub use service::ServiceCreateCommand;
pub use show::ShowCommand;
use crate::{docs, CommandGlobalOpts};
use ockam_node::Context;
mod accept;
mod create;
mod list;
mod service;
mod show;
#[derive(Clone, Debug, Args)]
#[command(arg_required_else_help = true, subcommand_required = true,
about=docs::about("Manage sharing invitations in Ockam Orchestrator"))]
pub struct ShareCommand {
#[command(subcommand)]
subcommand: ShareSubcommand,
}
#[derive(Clone, Debug, Subcommand)]
pub enum ShareSubcommand {
Accept(AcceptCommand),
Create(CreateCommand),
List(ListCommand),
Revoke,
Service(ServiceCreateCommand),
Show(ShowCommand),
}
impl ShareCommand {
pub async fn run(self, ctx: &Context, opts: CommandGlobalOpts) -> miette::Result<()> {
use ShareSubcommand::*;
match self.subcommand {
Accept(c) => c.run(ctx, opts).await,
Create(c) => c.run(ctx, opts).await,
List(c) => c.run(ctx, opts).await,
Revoke => todo!(),
Service(c) => c.run(ctx, opts).await,
Show(c) => c.run(ctx, opts).await,
}
}
pub fn name(&self) -> String {
match &self.subcommand {
ShareSubcommand::Accept(c) => c.name(),
ShareSubcommand::Create(c) => c.name(),
ShareSubcommand::List(c) => c.name(),
ShareSubcommand::Show(c) => c.name(),
ShareSubcommand::Service(c) => c.name(),
ShareSubcommand::Revoke => "revoke invitation".to_string(),
}
}
}