// ClientMode returns the mode based on the given URL. This is used to
// allow clients to let the getters decide which mode to use.
ClientMode(*url.URL) (ClientMode, error)
+
+ // SetClient allows a getter to know it's client
+ // in order to access client's Get functions or
+ // progress tracking.
+ SetClient(*Client)
}
// Getters is the mapping of scheme to the Getter implementation that will
Getters = map[string]Getter{
"file": new(FileGetter),
"git": new(GitGetter),
+ "gcs": new(GCSGetter),
"hg": new(HgGetter),
"s3": new(S3Getter),
"http": httpGetter,
//
// src is a URL, whereas dst is always just a file path to a folder. This
// folder doesn't need to exist. It will be created if it doesn't exist.
-func Get(dst, src string) error {
+func Get(dst, src string, opts ...ClientOption) error {
return (&Client{
Src: src,
Dst: dst,
Dir: true,
- Getters: Getters,
+ Options: opts,
}).Get()
}
// dst must be a directory. If src is a file, it will be downloaded
// into dst with the basename of the URL. If src is a directory or
// archive, it will be unpacked directly into dst.
-func GetAny(dst, src string) error {
+func GetAny(dst, src string, opts ...ClientOption) error {
return (&Client{
Src: src,
Dst: dst,
Mode: ClientModeAny,
- Getters: Getters,
+ Options: opts,
}).Get()
}
// GetFile downloads the file specified by src into the path specified by
// dst.
-func GetFile(dst, src string) error {
+func GetFile(dst, src string, opts ...ClientOption) error {
return (&Client{
Src: src,
Dst: dst,
Dir: false,
- Getters: Getters,
+ Options: opts,
}).Get()
}