use clap::Subcommand;
use crate::model::RfcPhase;
use crate::{
CommonAddArgs, CommonDeprecateArgs, CommonEditArgs, CommonGetArgs, CommonListArgs,
CommonRemoveArgs, CommonRenderArgs, CommonSetArgs, CommonShowArgs, CommonSupersedeArgs,
FinalizeStatus,
};
#[derive(Subcommand, Clone, Debug)]
pub(crate) enum RfcCommand {
#[command(
visible_alias = "ls",
after_help = "\
FILTERS:
Filter may be an RFC status, phase, or ID/title substring.
EXAMPLES:
govctl rfc list
govctl rfc list draft
govctl rfc list impl -n 5
govctl rfc list RFC-0002 -o json
"
)]
List(CommonListArgs),
#[command(after_help = "\
VALID FIELDS:
- title, version, status, phase, owners, refs
EXAMPLES:
govctl rfc get RFC-0001
govctl rfc get RFC-0001 title
govctl rfc get RFC-0001 refs
")]
Get(CommonGetArgs),
#[command(after_help = "\
EXAMPLES:
govctl rfc show RFC-0001
govctl rfc show RFC-0001 -o plain
NOTES:
- `show` prints human-readable rendered content.
- Use `get` for field/path-level inspection.
")]
Show(CommonShowArgs),
#[command(after_help = "\
EXAMPLES:
govctl rfc new \"Add incremental index rebuilding\"
govctl rfc new \"Add incremental index rebuilding\" --id RFC-0010
NOTES:
- Use `--id` only when you need to pin a specific RFC ID.
- New RFCs start as draft and can later be finalized.
")]
New {
title: String,
#[arg(long)]
id: Option<String>,
},
#[command(after_help = "\
EXAMPLES:
govctl rfc edit RFC-0001 version --set 1.2.0
govctl rfc edit RFC-0001 refs --add RFC-0002
govctl rfc edit RFC-0001 refs[0] --remove
")]
Edit(CommonEditArgs),
#[command(after_help = "\
VALID FIELDS:
String fields (use 'set'):
- title: RFC title
Array fields (use 'add' / 'remove'):
- owners, refs, sections
EXAMPLES:
govctl rfc set RFC-0001 title \"New Title\"
Use dedicated lifecycle verbs instead of `set` for:
- version → `govctl rfc bump`
- status → `govctl rfc finalize` / `govctl rfc deprecate` / `govctl rfc supersede`
- phase → `govctl rfc advance`
")]
Set(CommonSetArgs),
#[command(after_help = "\
VALID ARRAY FIELDS:
- refs: Cross-references to other RFCs (e.g., \"RFC-0002\")
- owners: RFC owners (e.g., \"@alice\")
EXAMPLES:
govctl rfc add RFC-0001 refs RFC-0002
govctl rfc add RFC-0001 owners @alice
")]
Add(CommonAddArgs),
#[command(after_help = "\
VALID ARRAY FIELDS:
- refs, owners
MATCHING OPTIONS:
- pattern: Substring match (default)
- --at N: Remove by index (0-based, negative = from end)
- --exact: Exact string match
- --regex: Regex pattern match
- --all: Remove all matches
EXAMPLES:
govctl rfc remove RFC-0001 refs RFC-0002 # Remove first match
govctl rfc remove RFC-0001 refs --at 1 # Remove by index
")]
Remove(CommonRemoveArgs),
#[command(after_help = "\
EXAMPLES:
govctl rfc bump RFC-0001 --patch -m \"Clarify examples\"
govctl rfc bump RFC-0001 --minor -c \"changed: New normative clause\"
NOTES:
- Exactly one of `--patch`, `--minor`, or `--major` must be chosen.
- Use `-m/--summary` for a release summary and `-c/--change` for detailed entries.
")]
Bump {
id: String,
#[arg(long, group = "bump_level")]
patch: bool,
#[arg(long, group = "bump_level")]
minor: bool,
#[arg(long, group = "bump_level")]
major: bool,
#[arg(short = 'm', long)]
summary: Option<String>,
#[arg(short = 'c', long = "change")]
changes: Vec<String>,
},
#[command(after_help = "\
EXAMPLES:
govctl rfc finalize RFC-0001 normative
govctl rfc finalize RFC-0001 deprecated
NOTES:
- Finalize is used once the RFC leaves draft state.
- Use `advance` to move phase after finalization.
")]
Finalize {
id: String,
#[arg(value_enum)]
status: FinalizeStatus,
},
#[command(after_help = "\
EXAMPLES:
govctl rfc advance RFC-0001 impl
govctl rfc advance RFC-0001 test
NOTES:
- Typical progression is `spec -> impl -> test -> stable`.
- Use this after the RFC has been finalized.
")]
Advance {
id: String,
#[arg(value_enum)]
phase: RfcPhase,
},
#[command(after_help = "\
EXAMPLES:
govctl rfc deprecate RFC-0001
govctl rfc deprecate RFC-0001 --force
")]
Deprecate(CommonDeprecateArgs),
#[command(after_help = "\
EXAMPLES:
govctl rfc supersede RFC-0001 --by RFC-0002
govctl rfc supersede RFC-0001 --by RFC-0002 --force
")]
Supersede(CommonSupersedeArgs),
#[command(after_help = "\
EXAMPLES:
govctl rfc render RFC-0001
govctl rfc render RFC-0001 --dry-run
")]
Render(CommonRenderArgs),
}