lotus/cli/client.go

57 lines
992 B
Go
Raw Normal View History

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 {
2019-07-18 23:16:23 +00:00
api, err := GetAPI(cctx)
2019-07-12 10:17:16 +00:00
if err != nil {
return err
}
2019-07-18 23:16:23 +00:00
ctx := ReqContext(cctx)
2019-07-12 10:17:16 +00:00
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 {
2019-07-18 23:16:23 +00:00
api, err := GetAPI(cctx)
2019-07-12 10:44:01 +00:00
if err != nil {
return err
}
2019-07-18 23:16:23 +00:00
ctx := ReqContext(cctx)
2019-07-12 10:44:01 +00:00
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
},
}