diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-08-04 17:28:41 +0200 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-08-08 01:35:50 +0200 |
commit | eadadf8dd81522b3bdb6ab2c5b7cd3f71cce45cf (patch) | |
tree | c271a815d32e7c2cda23aef6aec16004dda39bda /src | |
parent | Merge pull request 'update `forgejo-api` to v0.4.1' (#104) from api-0.4.1 int... (diff) | |
download | forgejo-cli-eadadf8dd81522b3bdb6ab2c5b7cd3f71cce45cf.tar.xz forgejo-cli-eadadf8dd81522b3bdb6ab2c5b7cd3f71cce45cf.zip |
chore: wiki file
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 3 | ||||
-rw-r--r-- | src/wiki.rs | 41 |
2 files changed, 44 insertions, 0 deletions
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<String>, + #[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!(), + } + } +} |