chore(sg): rfc flags are now position independent (#61529)

This commit is contained in:
Jean-Hadrien Chabran 2024-04-02 17:55:38 +02:00 committed by GitHub
parent 279ff01f23
commit 7eefd52f66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,17 @@ import (
"github.com/sourcegraph/sourcegraph/lib/errors"
)
// rfcFlags are the flags that are common to all subcommands of the rfc command. This allows to not have to remember which position the flags are
// to be inputted on the CLI.
var rfcFlags = []cli.Flag{
&cli.BoolFlag{
Name: "private",
Usage: "perform the RFC action on the private RFC drive",
Required: false,
Value: false,
},
}
var rfcCommand = &cli.Command{
Name: "rfc",
Usage: `List, search, and open Sourcegraph RFCs`,
@ -26,40 +37,33 @@ var rfcCommand = &cli.Command{
sg rfc list
# List all Private RFCs
sg rfc --private list
sg rfc list --private
# Search for a Public RFC
sg rfc search "search terms"
# Search for a Private RFC
sg rfc --private search "search terms"
sg rfc search --private "search terms"
# Open a specific Public RFC
sg rfc open 420
# Open a specific private RFC
sg rfc --private open 420
sg rfc open --private 420
# Create a new public RFC
sg rfc create "title"
# Create a new private RFC. Possible types: [solution]
sg rfc --private create --type <type> "title"
sg rfc create --private --type <type> "title"
`,
Category: category.Company,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "private",
Usage: "perform the RFC action on the private RFC drive",
Required: false,
Value: false,
},
},
Flags: rfcFlags,
Subcommands: []*cli.Command{
{
Name: "list",
ArgsUsage: " ",
Usage: "List Sourcegraph RFCs",
Name: "list",
Usage: "List Sourcegraph RFCs",
Flags: rfcFlags,
Action: func(c *cli.Context) error {
driveSpec := rfc.PublicDrive
if c.Bool("private") {
@ -71,6 +75,7 @@ sg rfc --private create --type <type> "title"
{
Name: "search",
ArgsUsage: "[query]",
Flags: rfcFlags,
Usage: "Search Sourcegraph RFCs",
Action: func(c *cli.Context) error {
driveSpec := rfc.PublicDrive
@ -86,6 +91,7 @@ sg rfc --private create --type <type> "title"
{
Name: "open",
ArgsUsage: "[number]",
Flags: rfcFlags,
Usage: "Open a Sourcegraph RFC - find and list RFC numbers with 'sg rfc list' or 'sg rfc search'",
Action: func(c *cli.Context) error {
driveSpec := rfc.PublicDrive
@ -100,14 +106,12 @@ sg rfc --private create --type <type> "title"
},
{
Name: "create",
ArgsUsage: "--type <type> [title...]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "type",
Usage: "the type of the RFC to create (valid: solution)",
Value: rfc.ProblemSolutionDriveTemplate.Name,
},
},
ArgsUsage: "[title...]",
Flags: append(rfcFlags, &cli.StringFlag{
Name: "type",
Usage: "the type of the RFC to create (valid: solution)",
Value: rfc.ProblemSolutionDriveTemplate.Name,
}),
Usage: "Create Sourcegraph RFCs",
Action: func(c *cli.Context) error {
driveSpec := rfc.PublicDrive