2019-07-12 10:17:16 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-07-16 16:07:08 +00:00
|
|
|
|
2019-07-12 10:17:16 +00:00
|
|
|
"gopkg.in/urfave/cli.v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
var clientCmd = &cli.Command{
|
|
|
|
Name: "client",
|
|
|
|
Usage: "Make deals, store data, retrieve data",
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
clientImportCmd,
|
2019-07-12 10:44:01 +00:00
|
|
|
clientLocalCmd,
|
2019-07-12 10:17:16 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var clientImportCmd = &cli.Command{
|
2019-07-12 10:44:01 +00:00
|
|
|
Name: "import",
|
|
|
|
Usage: "Import data",
|
2019-07-12 10:17:16 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
api, err := getAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
ctx := reqContext(cctx)
|
|
|
|
|
|
|
|
c, err := api.ClientImport(ctx, cctx.Args().First())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
fmt.Println(c.String())
|
|
|
|
return nil
|
|
|
|
},
|
2019-07-12 10:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var clientLocalCmd = &cli.Command{
|
|
|
|
Name: "local",
|
|
|
|
Usage: "List locally imported data",
|
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
api, err := getAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
ctx := reqContext(cctx)
|
|
|
|
|
|
|
|
list, err := api.ClientListImports(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range list {
|
|
|
|
fmt.Printf("%s %s %d %s\n", v.Key, v.FilePath, v.Size, v.Status)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|