start on rs list
This commit is contained in:
parent
79113bd304
commit
24911ffa24
2 changed files with 59 additions and 2 deletions
56
pkg/cmd/ruleset/list/list.go
Normal file
56
pkg/cmd/ruleset/list/list.go
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type ListOptions struct {
|
||||
HttpClient func() (*http.Client, error)
|
||||
IO *iostreams.IOStreams
|
||||
BaseRepo func() (ghrepo.Interface, error)
|
||||
|
||||
Organization string
|
||||
}
|
||||
|
||||
func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command {
|
||||
opts := &ListOptions{
|
||||
IO: f.IOStreams,
|
||||
HttpClient: f.HttpClient,
|
||||
}
|
||||
cmd := &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List rulesets for a repository or organization",
|
||||
Long: heredoc.Doc(`
|
||||
TODO
|
||||
`),
|
||||
Example: "TODO",
|
||||
Args: cobra.ExactArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
// support `-R, --repo` override
|
||||
opts.BaseRepo = f.BaseRepo
|
||||
|
||||
if runF != nil {
|
||||
return runF(opts)
|
||||
}
|
||||
|
||||
return listRun(opts)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&opts.Organization, "org", "o", "", "List organization-wide rules")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func listRun(opts *ListOptions) error {
|
||||
fmt.Println(opts.Organization)
|
||||
fmt.Println("LOL TODO")
|
||||
return nil
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package ruleset
|
|||
import (
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
cmdCheck "github.com/cli/cli/v2/pkg/cmd/ruleset/check"
|
||||
cmdList "github.com/cli/cli/v2/pkg/cmd/ruleset/list"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
|
@ -19,8 +20,8 @@ func NewCmdRuleset(f *cmdutil.Factory) *cobra.Command {
|
|||
}
|
||||
|
||||
cmdutil.EnableRepoOverride(cmd, f)
|
||||
// cmd.AddCommand(cmdList.NewCmdList(f, nil)
|
||||
// cmd.AddCommand(cmdList.NewCmdView(f, nil)
|
||||
cmd.AddCommand(cmdList.NewCmdList(f, nil))
|
||||
// cmd.AddCommand(cmdList.NewCmdView(f, nil))
|
||||
cmd.AddCommand(cmdCheck.NewCmdCheck(f, nil))
|
||||
|
||||
return cmd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue