MCPcopy
hub / github.com/mislav/hub / NewArgs

Function NewArgs

commands/args.go:184–217  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

182}
183
184func NewArgs(args []string) *Args {
185 var (
186 command string
187 params []string
188 noop bool
189 )
190
191 cmdIdx := findCommandIndex(args)
192 globalFlags := args[:cmdIdx]
193 if cmdIdx > 0 {
194 args = args[cmdIdx:]
195 for i := len(globalFlags) - 1; i >= 0; i-- {
196 if globalFlags[i] == noopFlag {
197 noop = true
198 globalFlags = append(globalFlags[:i], globalFlags[i+1:]...)
199 }
200 }
201 }
202
203 if len(args) != 0 {
204 command = args[0]
205 params = args[1:]
206 }
207
208 return &Args{
209 Executable: "git",
210 GlobalFlags: globalFlags,
211 Command: command,
212 Params: params,
213 Noop: noop,
214 beforeChain: make([]*cmd.Cmd, 0),
215 afterChain: make([]*cmd.Cmd, 0),
216 }
217}
218
219const (
220 noopFlag = "--noop"

Callers 15

TestNewArgsFunction · 0.85
TestArgs_WordsFunction · 0.85
TestArgs_InsertFunction · 0.85
TestArgs_RemoveFunction · 0.85
TestArgs_GlobalFlagsFunction · 0.85
TestParseRemoteNamesFunction · 0.85

Calls 1

findCommandIndexFunction · 0.85

Tested by 15

TestNewArgsFunction · 0.68
TestArgs_WordsFunction · 0.68
TestArgs_InsertFunction · 0.68
TestArgs_RemoveFunction · 0.68
TestArgs_GlobalFlagsFunction · 0.68
TestParseRemoteNamesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…