tideliftcli/main.go

50 lines
863 B
Go
Raw Normal View History

2019-05-14 02:24:02 +00:00
package main
import (
"fmt"
"log"
"os"
2019-05-14 02:52:22 +00:00
"strings"
2019-05-14 02:24:02 +00:00
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Commands = []cli.Command{
{
2019-05-14 03:30:09 +00:00
Name: "scan",
2019-05-14 03:59:51 +00:00
Aliases: []string{"s"},
2019-05-14 03:28:30 +00:00
Usage: "Scan a directory's manifests",
2019-05-14 02:24:02 +00:00
Action: func(c *cli.Context) error {
2019-05-14 03:37:32 +00:00
if len(c.Args()) > 0 {
return scan(c)
}
return cli.NewExitError("no directory provided", 5)
2019-05-14 02:24:02 +00:00
},
},
2019-05-14 03:59:51 +00:00
{
Name: "configure",
Aliases: []string{"c"},
Usage: "Configure the app",
Action: func(c *cli.Context) error {
return cli.NewExitError("No Configuration provided", 4)
},
},
2019-05-14 02:24:02 +00:00
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
2019-05-14 03:28:30 +00:00
func scan(c *cli.Context) error {
2019-05-14 02:52:22 +00:00
directory := c.Args().First()
2019-05-14 03:26:13 +00:00
fmt.Println(strings.Join(getAllManifests(directory), ", "))
2019-05-14 03:28:30 +00:00
// TODO, actually scan, don't just print names
2019-05-14 03:26:13 +00:00
return nil
}