Ready method define the variables required to Download.
(version string, args []string)
| 98 | |
| 99 | // Ready method define the variables required to Download. |
| 100 | func (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 | |
| 139 | func (pget *Pget) parseOptions(argv []string, version string) (*Options, error) { |
| 140 | var opts Options |