-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.go
More file actions
69 lines (53 loc) · 1.79 KB
/
cli.go
File metadata and controls
69 lines (53 loc) · 1.79 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package app
import (
"fmt"
"os"
"github.com/alecthomas/kong"
"github.com/aserto-dev/ds-load/cli/pkg/constants"
"github.com/aserto-dev/ds-load/cli/pkg/plugin"
"github.com/aserto-dev/ds-load/sdk/common/cc"
"github.com/aserto-dev/ds-load/sdk/common/version"
)
type CLI struct {
Exec ExecCmd `cmd:"" help:"import data in directory by running fetch, transform and publish" default:"withargs"`
Publish PublishCmd `cmd:"" help:"load data from stdin into directory"`
GetPlugin GetPluginCmd `cmd:"" help:"download plugin"`
SetDefaultPlugin SetDefaultPluginCmd `cmd:"" help:"sets a plugin as default"`
ListPlugins ListPluginsCmd `cmd:"" help:"list available plugins"`
Version VersionCmd `cmd:"" help:"version information"`
Config kong.ConfigFlag `short:"c" help:"Path to the config file. Any argument provided to the CLI will take precedence."`
Verbosity int `short:"v" type:"counter" help:"Use to increase output verbosity."`
}
type GetPluginCmd struct{}
func (getPlugin *GetPluginCmd) Run(c *cc.CommonCtx) error {
fmt.Println("not implemented")
return nil
}
type SetDefaultPluginCmd struct{}
func (defaultPlugin *SetDefaultPluginCmd) Run(c *cc.CommonCtx) error {
fmt.Println("not implemented")
return nil
}
type ListPluginsCmd struct{}
func (listPlugins *ListPluginsCmd) Run(c *cc.CommonCtx) error {
find, err := plugin.NewHomeDirFinder(true)
if err != nil {
return err
}
plugins, err := find.Find()
if err != nil {
return err
}
for _, p := range plugins {
os.Stdout.WriteString(p.Name + " " + p.Path + "\n")
}
return nil
}
type VersionCmd struct{}
func (cmd *VersionCmd) Run(c *cc.CommonCtx) error {
fmt.Printf("%s - %s\n",
constants.AppName,
version.GetInfo().String(),
)
return nil
}