package main import ( "fmt" "log" "os" "strings" "github.com/bmatcuk/doublestar" "github.com/urfave/cli" ) func main() { app := cli.NewApp() app.Commands = []cli.Command{ { Name: "upload", Aliases: []string{"u"}, Usage: "Upload a directory's manifests", Action: func(c *cli.Context) error { return upload(c) }, }, } err := app.Run(os.Args) if err != nil { log.Fatal(err) } } func upload(c *cli.Context) error { directory := c.Args().First() fmt.Println(strings.Join(getAllManifests(directory), ", ")) // TODO, actually upload, don't just print names return nil } func getAllManifests(directory string) []string { matchingFiles := make([]string, 0) for _, glob := range manifestGlobs() { pathGlob := fmt.Sprintf("%s/**/%s", directory, glob) files := getManifestGlobMatches(pathGlob) if len(files) > 0 { matchingFiles = append(matchingFiles, files...) } } return matchingFiles } func getManifestGlobMatches(glob string) []string { files, err := doublestar.Glob(glob) if err != nil { log.Fatal(err) } return files }