MCPcopy
hub / github.com/cli/cli / gardenRun

Function gardenRun

pkg/cmd/repo/garden/garden.go:125–304  ·  view source on GitHub ↗
(opts *GardenOptions)

Source from the content-addressed store, hash-verified

123}
124
125func gardenRun(opts *GardenOptions) error {
126 cs := opts.IO.ColorScheme()
127 out := opts.IO.Out
128
129 if runtime.GOOS == "windows" {
130 return errors.New("sorry :( this command only works on linux and macos")
131 }
132
133 if !opts.IO.IsStdoutTTY() {
134 return errors.New("must be connected to a terminal")
135 }
136
137 httpClient, err := opts.HttpClient()
138 if err != nil {
139 return err
140 }
141
142 var toView ghrepo.Interface
143 apiClient := api.NewClientFromHTTP(httpClient)
144 if opts.RepoArg == "" {
145 var err error
146 toView, err = opts.BaseRepo()
147 if err != nil {
148 return err
149 }
150 } else {
151 var err error
152 viewURL := opts.RepoArg
153 if !strings.Contains(viewURL, "/") {
154 cfg, err := opts.Config()
155 if err != nil {
156 return err
157 }
158 hostname, _ := cfg.Authentication().DefaultHost()
159 currentUser, err := api.CurrentLoginName(apiClient, hostname)
160 if err != nil {
161 return err
162 }
163 viewURL = currentUser + "/" + viewURL
164 }
165 toView, err = ghrepo.FromFullName(viewURL)
166 if err != nil {
167 return fmt.Errorf("argument error: %w", err)
168 }
169 }
170
171 seed := computeSeed(ghrepo.FullName(toView))
172 r := rand.New(rand.NewSource(seed))
173
174 termWidth, termHeight, err := utils.TerminalSize(out)
175 if err != nil {
176 return err
177 }
178
179 termWidth -= 10
180 termHeight -= 10
181
182 geo := &Geometry{

Callers 1

NewCmdGardenFunction · 0.85

Calls 15

moveMethod · 0.95
NewClientFromHTTPFunction · 0.92
CurrentLoginNameFunction · 0.92
FromFullNameFunction · 0.92
FullNameFunction · 0.92
computeSeedFunction · 0.85
getCommitsFunction · 0.85
plantGardenFunction · 0.85
drawGardenFunction · 0.85
isLeftFunction · 0.85
isRightFunction · 0.85
isUpFunction · 0.85

Tested by

no test coverage detected