MCPcopy
hub / github.com/larksuite/cli / newListCmd

Function newListCmd

cmd/skill/skill.go:61–100  ·  view source on GitHub ↗
(f *cmdutil.Factory)

Source from the content-addressed store, hash-verified

59}
60
61func newListCmd(f *cmdutil.Factory) *cobra.Command {
62 cmd := &cobra.Command{
63 Use: "list [name[/path]]",
64 Short: "List skills, or list one layer under a skill path (like ls)",
65 Example: ` lark-cli skills list # all skills: name, description, version
66 lark-cli skills list lark-doc # one layer under a skill (like ls)
67 lark-cli skills list lark-doc/references # one layer under a subdirectory`,
68 Args: cobra.ArbitraryArgs,
69 RunE: func(cmd *cobra.Command, args []string) error {
70 if len(args) > 1 {
71 return errs.NewValidationError(errs.SubtypeInvalidArgument,
72 "list takes at most 1 argument: [name[/path]]").
73 WithHint("run 'lark-cli skills list --help'")
74 }
75 r, err := newReader(f)
76 if err != nil {
77 return err
78 }
79 if len(args) == 0 {
80 skills, err := r.List()
81 if err != nil {
82 return err
83 }
84 output.PrintJson(f.IOStreams.Out, listEnvelope{OK: true, Skills: skills, Count: len(skills)})
85 return nil
86 }
87 entries, listed, err := r.ListPath(args[0])
88 if err != nil {
89 return err
90 }
91 output.PrintJson(f.IOStreams.Out, listPathEnvelope{OK: true, Path: listed, Entries: entries, Count: len(entries)})
92 return nil
93 },
94 }
95 // --json is a no-op (list is always JSON), accepted only to stay symmetric with read.
96 cmd.Flags().Bool("json", false, "no-op (list output is always JSON)")
97 cmdutil.SetRisk(cmd, "read")
98 cmdutil.DisableAuthCheck(cmd)
99 return cmd
100}
101
102func newReadCmd(f *cmdutil.Factory) *cobra.Command {
103 var asJSON bool

Callers 1

NewCmdSkillFunction · 0.85

Calls 9

NewValidationErrorFunction · 0.92
PrintJsonFunction · 0.92
SetRiskFunction · 0.92
DisableAuthCheckFunction · 0.92
newReaderFunction · 0.85
ListPathMethod · 0.80
BoolMethod · 0.65
WithHintMethod · 0.45
ListMethod · 0.45

Tested by

no test coverage detected