CLI-PR-001/002/003/004: Rename propose->proposal, add essential commands, improve accept, restrict story
- Rename 'propose' group to 'proposal' in surface, leaf help, and routing - Keep 'hf propose' as backward-compatible alias via groupAliases - Add essential subcommand group: list, create, update, delete - Accept command now shows generated story tasks in output - Accept command supports --json output - Task create blocks story/* types with helpful error message - All help text updated to use 'proposal' terminology
This commit is contained in:
@@ -187,8 +187,8 @@ func handleGroup(group help.Group, args []string) {
|
||||
case "support":
|
||||
handleSupportCommand(sub.Name, remaining)
|
||||
return
|
||||
case "propose":
|
||||
handleProposeCommand(sub.Name, remaining)
|
||||
case "proposal", "propose":
|
||||
handleProposalCommand(sub.Name, remaining)
|
||||
return
|
||||
case "comment":
|
||||
handleCommentCommand(sub.Name, remaining)
|
||||
@@ -309,7 +309,16 @@ func isHelpLikePath(args []string) bool {
|
||||
return isLeafHelpFlagOnly(args[len(args)-1:])
|
||||
}
|
||||
|
||||
// groupAliases maps legacy command names to their current group names.
|
||||
var groupAliases = map[string]string{
|
||||
"propose": "proposal",
|
||||
}
|
||||
|
||||
func findGroup(name string) (help.Group, bool) {
|
||||
// Resolve alias first
|
||||
if alias, ok := groupAliases[name]; ok {
|
||||
name = alias
|
||||
}
|
||||
for _, group := range help.CommandSurface() {
|
||||
if group.Name == name {
|
||||
return group, true
|
||||
@@ -691,7 +700,7 @@ func handleSupportCommand(subCmd string, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func handleProposeCommand(subCmd string, args []string) {
|
||||
func handleProposalCommand(subCmd string, args []string) {
|
||||
tokenFlag := ""
|
||||
var filtered []string
|
||||
for i := 0; i < len(args); i++ {
|
||||
@@ -711,33 +720,80 @@ func handleProposeCommand(subCmd string, args []string) {
|
||||
commands.RunProposeList(filtered, tokenFlag)
|
||||
case "get":
|
||||
if len(filtered) < 1 {
|
||||
output.Error("usage: hf propose get <propose-code>")
|
||||
output.Error("usage: hf proposal get <proposal-code>")
|
||||
}
|
||||
commands.RunProposeGet(filtered[0], tokenFlag)
|
||||
case "create":
|
||||
commands.RunProposeCreate(filtered, tokenFlag)
|
||||
case "update":
|
||||
if len(filtered) < 1 {
|
||||
output.Error("usage: hf propose update <propose-code> [--title ...] [--desc ...]")
|
||||
output.Error("usage: hf proposal update <proposal-code> [--title ...] [--desc ...]")
|
||||
}
|
||||
commands.RunProposeUpdate(filtered[0], filtered[1:], tokenFlag)
|
||||
case "accept":
|
||||
if len(filtered) < 1 {
|
||||
output.Error("usage: hf propose accept <propose-code> --milestone <milestone-code>")
|
||||
output.Error("usage: hf proposal accept <proposal-code> --milestone <milestone-code>")
|
||||
}
|
||||
commands.RunProposeAccept(filtered[0], filtered[1:], tokenFlag)
|
||||
case "reject":
|
||||
if len(filtered) < 1 {
|
||||
output.Error("usage: hf propose reject <propose-code> [--reason <reason>]")
|
||||
output.Error("usage: hf proposal reject <proposal-code> [--reason <reason>]")
|
||||
}
|
||||
commands.RunProposeReject(filtered[0], filtered[1:], tokenFlag)
|
||||
case "reopen":
|
||||
if len(filtered) < 1 {
|
||||
output.Error("usage: hf propose reopen <propose-code>")
|
||||
output.Error("usage: hf proposal reopen <proposal-code>")
|
||||
}
|
||||
commands.RunProposeReopen(filtered[0], tokenFlag)
|
||||
case "essential":
|
||||
handleProposalEssentialCommand(filtered, tokenFlag)
|
||||
default:
|
||||
output.Errorf("hf propose %s is not implemented yet", subCmd)
|
||||
output.Errorf("hf proposal %s is not implemented yet", subCmd)
|
||||
}
|
||||
}
|
||||
|
||||
func handleProposalEssentialCommand(args []string, tokenFlag string) {
|
||||
essentialCommands := []help.Command{
|
||||
{Name: "list", Description: "List essentials for a proposal", Permitted: true},
|
||||
{Name: "create", Description: "Create an essential", Permitted: true},
|
||||
{Name: "update", Description: "Update an essential", Permitted: true},
|
||||
{Name: "delete", Description: "Delete an essential", Permitted: true},
|
||||
}
|
||||
|
||||
if len(args) == 0 || isHelpFlagOnly(args) {
|
||||
fmt.Print(help.RenderGroupHelp("proposal essential", essentialCommands))
|
||||
return
|
||||
}
|
||||
|
||||
subCmd := args[0]
|
||||
remaining := args[1:]
|
||||
|
||||
if isLeafHelpFlagOnly(remaining) {
|
||||
if text, ok := help.RenderLeafHelp("proposal/essential", subCmd); ok {
|
||||
fmt.Print(text)
|
||||
return
|
||||
}
|
||||
fmt.Printf("hf proposal essential %s\n", subCmd)
|
||||
return
|
||||
}
|
||||
|
||||
switch subCmd {
|
||||
case "list":
|
||||
commands.RunEssentialList(remaining, tokenFlag)
|
||||
case "create":
|
||||
commands.RunEssentialCreate(remaining, tokenFlag)
|
||||
case "update":
|
||||
if len(remaining) < 1 {
|
||||
output.Error("usage: hf proposal essential update <essential-code> [--title ...] [--type ...] [--desc ...]")
|
||||
}
|
||||
commands.RunEssentialUpdate(remaining[0], remaining[1:], tokenFlag)
|
||||
case "delete":
|
||||
if len(remaining) < 1 {
|
||||
output.Error("usage: hf proposal essential delete <essential-code> --proposal <proposal-code>")
|
||||
}
|
||||
commands.RunEssentialDeleteFull(remaining[0], remaining[1:], tokenFlag)
|
||||
default:
|
||||
output.Errorf("hf proposal essential %s is not implemented yet", subCmd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user