MCPcopy Index your code
hub / github.com/cli/cli / NewCmdConfigGet

Function NewCmdConfigGet

pkg/cmd/config/get/get.go:22–53  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*GetOptions) error)

Source from the content-addressed store, hash-verified

20}
21
22func NewCmdConfigGet(f *cmdutil.Factory, runF func(*GetOptions) error) *cobra.Command {
23 opts := &GetOptions{
24 IO: f.IOStreams,
25 }
26
27 cmd := &cobra.Command{
28 Use: "get <key>",
29 Short: "Print the value of a given configuration key",
30 Example: heredoc.Doc(`
31 $ gh config get git_protocol
32 `),
33 Args: cobra.ExactArgs(1),
34 RunE: func(cmd *cobra.Command, args []string) error {
35 config, err := f.Config()
36 if err != nil {
37 return err
38 }
39 opts.Config = config
40 opts.Key = args[0]
41
42 if runF != nil {
43 return runF(opts)
44 }
45
46 return getRun(opts)
47 },
48 }
49
50 cmd.Flags().StringVarP(&opts.Hostname, "host", "h", "", "Get per-host setting")
51
52 return cmd
53}
54
55func getRun(opts *GetOptions) error {
56 // search keyring storage when fetching the `oauth_token` value

Callers 1

TestNewCmdConfigGetFunction · 0.85

Calls 2

getRunFunction · 0.70
ConfigMethod · 0.65

Tested by 1

TestNewCmdConfigGetFunction · 0.68