diff --git a/src/main.rs b/src/main.rs index 59a70da..c26081f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ mod prs; mod release; mod repo; mod user; +mod wiki; #[derive(Parser, Debug)] pub struct App { @@ -30,6 +31,7 @@ pub enum Command { Repo(repo::RepoCommand), Issue(issues::IssueCommand), Pr(prs::PrCommand), + Wiki(wiki::WikiCommand), #[command(name = "whoami")] WhoAmI { #[clap(long, short)] @@ -61,6 +63,7 @@ async fn main() -> eyre::Result<()> { Command::Repo(subcommand) => subcommand.run(&mut keys, host_name).await?, Command::Issue(subcommand) => subcommand.run(&mut keys, host_name).await?, Command::Pr(subcommand) => subcommand.run(&mut keys, host_name).await?, + Command::Wiki(subcommand) => subcommand.run(&mut keys, host_name).await?, Command::WhoAmI { remote } => { let url = repo::RepoInfo::get_current(host_name, None, remote.as_deref()) .wrap_err("could not find host, try specifying with --host")? diff --git a/src/wiki.rs b/src/wiki.rs new file mode 100644 index 0000000..91792ad --- /dev/null +++ b/src/wiki.rs @@ -0,0 +1,41 @@ +use clap::{Args, Subcommand}; + +use crate::repo::{RepoArg, RepoInfo}; + +#[derive(Args, Clone, Debug)] +pub struct WikiCommand { + /// The local git remote that points to the repo to operate on. + #[clap(long, short = 'R')] + remote: Option, + #[clap(subcommand)] + command: WikiSubcommand, +} + +#[derive(Subcommand, Clone, Debug)] +pub enum WikiSubcommand {} + +impl WikiCommand { + pub async fn run(self, keys: &mut crate::KeyInfo, host_name: Option<&str>) -> eyre::Result<()> { + use WikiSubcommand::*; + + let repo = RepoInfo::get_current(host_name, self.repo(), self.remote.as_deref())?; + let api = keys.get_api(repo.host_url()).await?; + let repo = repo.name().ok_or_else(|| self.no_repo_error())?; + + match self.command {} + } + + fn repo(&self) -> Option<&RepoArg> { + use WikiSubcommand::*; + match &self.command { + _ => todo!(), + } + } + + fn no_repo_error(&self) -> eyre::Error { + use WikiSubcommand::*; + match &self.command { + _ => todo!(), + } + } +}