mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-23 10:21:48 +01:00
chore: wiki file
This commit is contained in:
parent
3e334c7c4e
commit
eadadf8dd8
2 changed files with 44 additions and 0 deletions
|
@ -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")?
|
||||
|
|
41
src/wiki.rs
Normal file
41
src/wiki.rs
Normal file
|
@ -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!(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue