MCPcopy Create free account
hub / github.com/Code-Hex/pget / parseOptions

Method parseOptions

pget.go:139–169  ·  view source on GitHub ↗
(argv []string, version string)

Source from the content-addressed store, hash-verified

137}
138
139func (pget *Pget) parseOptions(argv []string, version string) (*Options, error) {
140 var opts Options
141 if len(argv) == 0 {
142 stdout.Write(opts.usage(version))
143 return nil, makeIgnoreErr()
144 }
145
146 o, err := opts.parse(argv, version)
147 if err != nil {
148 return nil, errors.Wrap(err, "failed to parse command line options")
149 }
150
151 if opts.Help {
152 stdout.Write(opts.usage(version))
153 return nil, makeIgnoreErr()
154 }
155
156 if opts.Update {
157 result, err := opts.isupdate(version)
158 if err != nil {
159 return nil, errors.Wrap(err, "failed to parse command line options")
160 }
161
162 stdout.Write(result)
163 return nil, makeIgnoreErr()
164 }
165
166 pget.args = o
167
168 return &opts, nil
169}
170
171func (pget *Pget) parseURLs() error {
172

Callers 3

ReadyMethod · 0.95
TestShowhelpFunction · 0.80
TestShowisupdateFunction · 0.80

Calls 4

usageMethod · 0.95
parseMethod · 0.95
isupdateMethod · 0.95
makeIgnoreErrFunction · 0.85

Tested by 2

TestShowhelpFunction · 0.64
TestShowisupdateFunction · 0.64