use std::path::PathBuf;
use clap::{Args, Parser, Subcommand};
#[derive(Debug, Parser)]
#[command(name = "wipe", version, about, long_about = None, propagate_version = true)]
pub struct Cli {
#[arg(long, global = true)]
pub json: bool,
#[arg(short = 'C', long = "cwd", global = true, value_name = "PATH")]
pub cwd: Option<PathBuf>,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
Init(InitArgs),
Status,
#[command(subcommand)]
Board(BoardCmd),
#[command(subcommand)]
List(ListCmd),
#[command(subcommand)]
Ticket(TicketCmd),
#[command(subcommand)]
Comment(CommentCmd),
#[command(subcommand)]
Label(LabelCmd),
#[command(subcommand)]
Media(MediaCmd),
#[command(subcommand)]
Forum(ForumCmd),
Serve(ServeArgs),
Config {
#[arg(long)]
global: bool,
#[command(subcommand)]
cmd: ConfigCmd,
},
Doctor,
Skill {
#[command(subcommand)]
cmd: Option<SkillCmd>,
},
Completions {
shell: clap_complete::Shell,
},
}
#[derive(Debug, Args)]
pub struct InitArgs {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(long)]
pub name: Option<String>,
#[arg(long, short = 'y')]
pub yes: bool,
#[arg(long, value_name = "KIND")]
pub starter: Option<String>,
}
#[derive(Debug, Subcommand)]
pub enum SkillCmd {
Show,
Install(SkillInstallArgs),
Path(SkillInstallArgs),
}
#[derive(Debug, Args, Clone)]
pub struct SkillInstallArgs {
#[arg(long, value_name = "TARGET")]
pub target: Option<String>,
#[arg(long)]
pub global: bool,
#[arg(long, value_name = "PATH")]
pub dir: Option<PathBuf>,
#[arg(long)]
pub force: bool,
}
#[derive(Debug, Subcommand)]
pub enum BoardCmd {
Show,
Rename {
name: String,
},
}
#[derive(Debug, Subcommand)]
pub enum ListCmd {
Show,
Add {
name: String,
},
Rename {
id: String,
name: String,
},
Move {
id: String,
index: usize,
},
Remove {
id: String,
#[arg(long)]
force: bool,
},
}
#[derive(Debug, Subcommand)]
pub enum TicketCmd {
Create(TicketCreateArgs),
Show {
id: String,
},
Edit(TicketEditArgs),
Move {
id: String,
#[arg(long)]
to: String,
#[arg(long)]
pos: Option<usize>,
},
Assign {
id: String,
who: String,
#[arg(long)]
remove: bool,
},
Close {
id: String,
},
Reopen {
id: String,
},
Delete {
id: String,
#[arg(long)]
yes: bool,
},
List(TicketListArgs),
}
#[derive(Debug, Args)]
pub struct TicketCreateArgs {
#[arg(long, short)]
pub title: String,
#[arg(long, short)]
pub body: Option<String>,
#[arg(long)]
pub priority: Option<String>,
#[arg(long, short = 'l')]
pub list: Option<String>,
#[arg(long = "label", value_name = "LABEL")]
pub labels: Vec<String>,
#[arg(long = "assignee", value_name = "WHO")]
pub assignees: Vec<String>,
}
#[derive(Debug, Args)]
pub struct TicketEditArgs {
pub id: String,
#[arg(long)]
pub title: Option<String>,
#[arg(long)]
pub body: Option<String>,
#[arg(long)]
pub priority: Option<String>,
}
#[derive(Debug, Args)]
pub struct TicketListArgs {
#[arg(long)]
pub list: Option<String>,
#[arg(long)]
pub label: Option<String>,
}
#[derive(Debug, Subcommand)]
pub enum CommentCmd {
Add {
ticket: String,
#[arg(long, short)]
body: String,
#[arg(long)]
author: Option<String>,
},
List {
ticket: String,
},
}
#[derive(Debug, Subcommand)]
pub enum LabelCmd {
Create {
name: String,
#[arg(long)]
color: Option<String>,
#[arg(long)]
description: Option<String>,
},
List,
Delete {
name: String,
},
Assign {
ticket: String,
name: String,
},
Remove {
ticket: String,
name: String,
},
}
#[derive(Debug, Subcommand)]
pub enum MediaCmd {
Add {
ticket: String,
path: PathBuf,
},
List {
ticket: String,
},
Remove {
ticket: String,
name: String,
},
}
#[derive(Debug, Subcommand)]
pub enum ForumCmd {
Post(ForumPostArgs),
Reply(ForumReplyArgs),
Show {
id: String,
#[arg(long)]
depth: Option<usize>,
},
List {
#[arg(long)]
label: Option<String>,
#[arg(long)]
author: Option<String>,
#[arg(long)]
limit: Option<usize>,
},
Search(ForumSearchArgs),
Edit {
id: String,
#[arg(long, short)]
body: String,
},
Delete {
id: String,
#[arg(long)]
yes: bool,
},
Watch(ForumWatchArgs),
}
#[derive(Debug, Args)]
pub struct ForumPostArgs {
#[arg(long, short)]
pub title: String,
#[arg(long, short)]
pub body: Option<String>,
#[arg(long = "label", value_name = "LABEL")]
pub labels: Vec<String>,
#[arg(long = "ref", value_name = "REF")]
pub refs: Vec<String>,
#[arg(long = "attach", value_name = "PATH")]
pub attach: Vec<PathBuf>,
#[arg(long)]
pub author: Option<String>,
}
#[derive(Debug, Args)]
pub struct ForumReplyArgs {
pub id: String,
#[arg(long, short)]
pub body: String,
#[arg(long = "label", value_name = "LABEL")]
pub labels: Vec<String>,
#[arg(long = "ref", value_name = "REF")]
pub refs: Vec<String>,
#[arg(long = "attach", value_name = "PATH")]
pub attach: Vec<PathBuf>,
#[arg(long)]
pub author: Option<String>,
}
#[derive(Debug, Args)]
pub struct ForumSearchArgs {
pub pattern: Option<String>,
#[arg(long)]
pub author: Option<String>,
#[arg(long = "label", value_name = "LABEL")]
pub labels: Vec<String>,
#[arg(long)]
pub scope: Option<String>,
#[arg(long)]
pub depth: Option<usize>,
#[arg(long)]
pub titles: bool,
#[arg(long)]
pub limit: Option<usize>,
#[arg(long = "case-sensitive")]
pub case_sensitive: bool,
}
#[derive(Debug, Args)]
pub struct ForumWatchArgs {
#[arg(long)]
pub pattern: Option<String>,
#[arg(long)]
pub author: Option<String>,
#[arg(long = "label", value_name = "LABEL")]
pub labels: Vec<String>,
#[arg(long)]
pub scope: Option<String>,
#[arg(long, default_value = "1000")]
pub interval: u64,
#[arg(long)]
pub replay: bool,
}
#[derive(Debug, Args)]
pub struct ServeArgs {
#[arg(long)]
pub port: Option<u16>,
#[arg(long)]
pub open: bool,
#[arg(long, value_name = "SECS")]
pub idle: Option<u64>,
}
#[derive(Debug, Subcommand)]
pub enum ConfigCmd {
Show,
Get {
key: String,
},
Set {
key: String,
value: String,
},
}