-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
gist_view.go
37 lines (31 loc) · 1.08 KB
/
gist_view.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/completers/gh_completer/cmd/action"
"github.com/spf13/cobra"
)
var gist_viewCmd = &cobra.Command{
Use: "view [<id> | <url>]",
Short: "View a gist",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(gist_viewCmd).Standalone()
gist_viewCmd.Flags().StringP("filename", "f", "", "Display a single file from the gist")
gist_viewCmd.Flags().Bool("files", false, "List file names from the gist")
gist_viewCmd.Flags().BoolP("raw", "r", false, "Print raw instead of rendered gist contents")
gist_viewCmd.Flags().BoolP("web", "w", false, "Open gist in the browser")
gistCmd.AddCommand(gist_viewCmd)
carapace.Gen(gist_viewCmd).FlagCompletion(carapace.ActionMap{
"filename": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if len(c.Args) > 0 {
return action.ActionGistFiles(gist_viewCmd, c.Args[0])
} else {
return carapace.ActionValues()
}
}),
})
carapace.Gen(gist_viewCmd).PositionalCompletion(
action.ActionGists(gist_viewCmd),
)
}