use std::path::PathBuf;
use clap::Subcommand;
use crate::TickStatus;
use crate::model::ClauseKind;
use crate::{
CommonDeleteArgs, CommonDeprecateArgs, CommonGetArgs, CommonListArgs, CommonSetArgs,
CommonShowArgs, CommonSupersedeArgs,
};
#[derive(Subcommand, Clone, Debug)]
pub(crate) enum ClauseCommand {
#[command(
visible_alias = "ls",
after_help = "\
FILTERS:
Filter may be a clause kind, status, clause ID, or title substring.
EXAMPLES:
govctl clause list
govctl clause list normative
govctl clause list RFC-0002:C-SCOPE
"
)]
List(CommonListArgs),
#[command(after_help = "\
VALID FIELDS:
- title, kind, text, status, anchors, superseded_by, since
EXAMPLES:
govctl clause get RFC-0001:C-SCOPE
govctl clause get RFC-0001:C-SCOPE text
govctl clause get RFC-0001:C-SCOPE anchors
")]
Get(CommonGetArgs),
#[command(after_help = "\
EXAMPLES:
govctl clause show RFC-0001:C-SCOPE
govctl clause show RFC-0001:C-SCOPE -o plain
")]
Show(CommonShowArgs),
#[command(after_help = "\
EXAMPLES:
govctl clause new RFC-0001:C-SCOPE \"Scope\"
govctl clause new RFC-0001:C-SCOPE \"Scope\" --section Specification --kind normative
NOTES:
- Clause IDs are scoped to an RFC: `RFC-XXXX:C-NAME`.
- Use `--kind informative` for explanatory clauses.
")]
New {
clause_id: String,
title: String,
#[arg(short = 's', long, default_value = "Specification")]
section: String,
#[arg(short = 'k', long, value_enum, default_value = "normative")]
kind: ClauseKind,
},
#[command(after_help = "\
EXAMPLES:
govctl clause edit RFC-0001:C-SUMMARY text --set \"Updated clause text\"
govctl clause edit RFC-0001:C-SUMMARY text --stdin
govctl clause edit RFC-0001:C-SUMMARY title --set \"New Title\"
govctl clause edit RFC-0001:C-SUMMARY kind --set informative
LEGACY SUGAR:
govctl clause edit RFC-0001:C-SUMMARY --text \"Updated clause text\"
govctl clause edit RFC-0001:C-SUMMARY --stdin
")]
Edit {
id: String,
path: Option<String>,
#[arg(long, group = "clause_edit_action", num_args = 0..=1)]
set: Option<Option<String>>,
#[arg(long, group = "clause_edit_action", num_args = 0..=1)]
add: Option<Option<String>>,
#[arg(long, group = "clause_edit_action", num_args = 0..=1)]
remove: Option<Option<String>>,
#[arg(long, group = "clause_edit_action")]
tick: Option<TickStatus>,
#[arg(long)]
stdin: bool,
#[arg(long, allow_hyphen_values = true)]
at: Option<i32>,
#[arg(long)]
exact: bool,
#[arg(long)]
regex: bool,
#[arg(long)]
all: bool,
#[arg(long, group = "text_source")]
text: Option<String>,
#[arg(long, group = "text_source")]
text_file: Option<PathBuf>,
},
#[command(after_help = "\
VALID FIELDS:
String fields (use 'set' or `edit ... --set`):
- title: Clause title
- kind: Clause kind (normative|informative)
- text: Clause text content
Array fields (use 'add' / 'remove' or `edit ... --add/--remove`):
- anchors: Cross-reference anchors
EXAMPLES:
govctl clause set RFC-0001:C-SUMMARY title \"New Title\"
govctl clause set RFC-0001:C-SUMMARY kind informative
govctl clause set RFC-0001:C-SUMMARY text --stdin
Use dedicated verbs instead of `set` for:
- status / superseded_by → `govctl clause deprecate` / `govctl clause supersede`
- since → `govctl rfc bump` / `govctl rfc finalize`
")]
Set(CommonSetArgs),
#[command(after_help = "\
EXAMPLES:
govctl clause delete RFC-0001:C-SCOPE
govctl clause delete RFC-0001:C-SCOPE --force
")]
Delete(CommonDeleteArgs),
#[command(after_help = "\
EXAMPLES:
govctl clause deprecate RFC-0001:C-SCOPE
govctl clause deprecate RFC-0001:C-SCOPE --force
")]
Deprecate(CommonDeprecateArgs),
#[command(after_help = "\
EXAMPLES:
govctl clause supersede RFC-0001:C-SCOPE --by RFC-0001:C-NEW-SCOPE
govctl clause supersede RFC-0001:C-SCOPE --by RFC-0001:C-NEW-SCOPE --force
")]
Supersede(CommonSupersedeArgs),
}