/
cmd.go
48 lines (38 loc) · 1.06 KB
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package index
import (
"path/filepath"
"github.com/spf13/cobra"
"github.com/dsh2dsh/edgar/cmd/internal/common"
)
var (
edgarDataDir string
Cmd = cobra.Command{
Use: "archive",
Short: "EDGAR index files",
}
downloadCmd = cobra.Command{
Use: "download index [files...]",
Short: "Recursively download files from EDGAR's /Archives/edgar/index",
Example: `
- Download all master.gz files from full-index:
$ edgar index download full-index master.gz
- Download all files from daily-index:
$ edgar index download daily-index`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
client, err := common.NewClient()
cobra.CheckErr(err)
d := NewDownload(client, newDownloadDir(edgarDataDir)).
WithProcsLimit(downloadProcs)
if len(args) > 1 {
d.WithNeedFiles(args[1:])
}
cobra.CheckErr(d.Download(filepath.Join(edgarPath, args[0])))
},
}
)
func init() {
Cmd.AddCommand(&downloadCmd)
downloadCmd.Flags().StringVarP(&edgarDataDir, "datadir", "d", "./",
"store EDGAR files into this directory")
}