package mfer import ( "fmt" "log" "os" "path/filepath" "github.com/pterm/pterm" "github.com/urfave/cli/v2" ) func printBanner(Appname, Version, Buildarch string) { s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString(Appname)).Srender() pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter } func disableStyling() { pterm.DisableColor() pterm.DisableStyling() pterm.Debug.Prefix.Text = "" pterm.Info.Prefix.Text = "" pterm.Success.Prefix.Text = "" pterm.Warning.Prefix.Text = "" pterm.Error.Prefix.Text = "" pterm.Fatal.Prefix.Text = "" } func init() { if _, exists := os.LookupEnv("NO_COLOR"); exists { disableStyling() } } func Run(Appname, Version, Buildarch string) int { printBanner(Appname, Version, Buildarch) app := &cli.App{ Name: Appname, Usage: "Manifest generator", Version: Version, EnableBashCompletion: true, Commands: []*cli.Command{ { Name: "generate", Aliases: []string{"gen"}, Usage: "Generate manifest file", Action: func(c *cli.Context) error { return generateManifest(c.String("input"), c.String("output")) }, Flags: []cli.Flag{ &cli.StringFlag{ Name: "input", Value: ".", Aliases: []string{"i"}, Usage: "Specify input directory.", }, &cli.StringFlag{ Name: "output", Value: "./index.mf", Aliases: []string{"o"}, Usage: "Specify output filename", }, }, }, }, } err := app.Run(os.Args) if err != nil { log.Fatal(err) return 1 } return 0 } func generateManifest(path, outputFilename string) error { fmt.Println("generateManifest()") walkErr := filepath.Walk(path, func(itemPath string, info os.FileInfo, err error) error { fmt.Println(itemPath) return nil }) if walkErr != nil { log.Fatal(walkErr) return walkErr } return nil }