File: client.go

package info (click to toggle)
gh 2.46.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,548 kB
  • sloc: sh: 227; makefile: 117
file content (22 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package client

import (
	"os"

	"github.com/cli/cli/v2/pkg/cmd/project/shared/queries"
	"github.com/cli/cli/v2/pkg/cmdutil"
)

func New(f *cmdutil.Factory) (*queries.Client, error) {
	if f.HttpClient == nil {
		// This is for compatibility with tests that exercise Cobra command functionality.
		// These tests do not define a `HttpClient` nor do they need to.
		return nil, nil
	}

	httpClient, err := f.HttpClient()
	if err != nil {
		return nil, err
	}
	return queries.NewClient(httpClient, os.Getenv("GH_HOST"), f.IOStreams), nil
}