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

Method Ready

pget.go:100–137  ·  view source on GitHub ↗

Ready method define the variables required to Download.

(version string, args []string)

Source from the content-addressed store, hash-verified

98
99// Ready method define the variables required to Download.
100func (pget *Pget) Ready(version string, args []string) error {
101 opts, err := pget.parseOptions(args, version)
102 if err != nil {
103 return errors.Wrap(errTop(err), "failed to parse command line args")
104 }
105
106 if opts.Trace {
107 pget.Trace = opts.Trace
108 }
109
110 if opts.Timeout > 0 {
111 pget.timeout = opts.Timeout
112 }
113
114 if err := pget.parseURLs(); err != nil {
115 return errors.Wrap(err, "failed to parse of url")
116 }
117
118 if opts.NumConnection > warningNumConnection && !prompter.YN(warningMessage, false) {
119 return makeIgnoreErr()
120 }
121
122 pget.Procs = opts.NumConnection * len(pget.URLs)
123
124 if opts.Output != "" {
125 pget.Output = opts.Output
126 }
127
128 if opts.UserAgent != "" {
129 pget.useragent = opts.UserAgent
130 }
131
132 if opts.Referer != "" {
133 pget.referer = opts.Referer
134 }
135
136 return nil
137}
138
139func (pget *Pget) parseOptions(argv []string, version string) (*Options, error) {
140 var opts Options

Callers 2

RunMethod · 0.95
TestParts_of_readyFunction · 0.80

Calls 4

parseOptionsMethod · 0.95
parseURLsMethod · 0.95
errTopFunction · 0.85
makeIgnoreErrFunction · 0.85

Tested by 1

TestParts_of_readyFunction · 0.64