2024-12-08 17:23:54 +00:00
|
|
|
//
|
|
|
|
use clap::Parser;
|
2024-12-04 19:37:39 +00:00
|
|
|
|
2024-12-08 17:23:54 +00:00
|
|
|
use crate::{
|
|
|
|
execute::Execute,
|
|
|
|
nextcloud::{
|
2024-12-14 08:05:34 +00:00
|
|
|
card::NextcloudCardCommand,
|
2024-12-11 20:46:10 +00:00
|
|
|
deck::NextcloudDeckCommand,
|
2024-12-14 08:05:34 +00:00
|
|
|
model::{NextcloudBoardId, NextcloudHostname, NextcloudPassword, NextcloudUsername},
|
2024-12-08 17:23:54 +00:00
|
|
|
stack::NextcloudStackCommand,
|
|
|
|
},
|
|
|
|
FullCtx,
|
2024-11-30 18:04:48 +00:00
|
|
|
};
|
2024-11-30 11:30:36 +00:00
|
|
|
|
2024-12-08 22:15:23 +00:00
|
|
|
pub(crate) mod card;
|
2024-12-08 17:23:54 +00:00
|
|
|
pub(crate) mod client;
|
2024-12-11 20:46:10 +00:00
|
|
|
pub(crate) mod deck;
|
2024-12-08 17:23:54 +00:00
|
|
|
pub(crate) mod model;
|
|
|
|
mod stack;
|
2024-11-30 11:30:36 +00:00
|
|
|
|
2024-12-14 08:02:19 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
2024-11-30 11:30:36 +00:00
|
|
|
|
2024-12-07 18:11:24 +00:00
|
|
|
pub(crate) struct DeckClient<'ctx> {
|
|
|
|
ctx: &'ctx FullCtx,
|
|
|
|
hostname: &'ctx NextcloudHostname,
|
|
|
|
username: &'ctx NextcloudUsername,
|
|
|
|
password: &'ctx NextcloudPassword,
|
2024-11-30 11:30:36 +00:00
|
|
|
}
|
2024-12-08 14:39:03 +00:00
|
|
|
|
2024-12-08 17:23:54 +00:00
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
pub(crate) enum NextcloudCommand {
|
|
|
|
#[clap(subcommand)]
|
2024-12-11 20:46:10 +00:00
|
|
|
Deck(NextcloudDeckCommand),
|
2024-12-08 17:23:54 +00:00
|
|
|
#[clap(subcommand)]
|
|
|
|
Stack(NextcloudStackCommand),
|
|
|
|
#[clap(subcommand)]
|
|
|
|
Card(NextcloudCardCommand),
|
|
|
|
}
|
|
|
|
impl Execute for NextcloudCommand {
|
2024-12-15 20:07:34 +00:00
|
|
|
async fn execute(self, ctx: &FullCtx) -> color_eyre::Result<()> {
|
2024-12-08 17:23:54 +00:00
|
|
|
match self {
|
2024-12-11 20:46:10 +00:00
|
|
|
NextcloudCommand::Deck(cmd) => cmd.execute(ctx).await,
|
2024-12-08 17:23:54 +00:00
|
|
|
NextcloudCommand::Stack(cmd) => cmd.execute(ctx).await,
|
|
|
|
NextcloudCommand::Card(cmd) => cmd.execute(ctx).await,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, derive_more::From, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
|
|
|
|
pub struct NextcloudConfig {
|
|
|
|
pub(crate) hostname: NextcloudHostname,
|
|
|
|
pub(crate) username: NextcloudUsername,
|
|
|
|
pub(crate) password: NextcloudPassword,
|
|
|
|
pub(crate) board_id: NextcloudBoardId,
|
|
|
|
}
|