works but has a weird bug
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.eeqj.de/sneak/mfer/mfer"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
@@ -20,12 +22,12 @@ type CLIApp struct {
|
||||
app *cli.App
|
||||
}
|
||||
|
||||
func (m *CLIApp) printBanner() {
|
||||
s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString(m.appname)).Srender()
|
||||
func (mfa *CLIApp) printBanner() {
|
||||
s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString(mfa.appname)).Srender()
|
||||
pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
|
||||
}
|
||||
|
||||
func (m *CLIApp) disableStyling() {
|
||||
func (mfa *CLIApp) disableStyling() {
|
||||
pterm.DisableColor()
|
||||
pterm.DisableStyling()
|
||||
pterm.Debug.Prefix.Text = ""
|
||||
@@ -36,19 +38,19 @@ func (m *CLIApp) disableStyling() {
|
||||
pterm.Fatal.Prefix.Text = ""
|
||||
}
|
||||
|
||||
func (m *CLIApp) run() {
|
||||
func (mfa *CLIApp) run() {
|
||||
|
||||
if NO_COLOR {
|
||||
// shoutout to rob pike who thinks it's juvenile
|
||||
m.disableStyling()
|
||||
mfa.disableStyling()
|
||||
}
|
||||
|
||||
m.printBanner()
|
||||
mfa.printBanner()
|
||||
|
||||
m.app = &cli.App{
|
||||
Name: m.appname,
|
||||
mfa.app = &cli.App{
|
||||
Name: mfa.appname,
|
||||
Usage: "Manifest generator",
|
||||
Version: m.version,
|
||||
Version: mfa.version,
|
||||
EnableBashCompletion: true,
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
@@ -56,7 +58,7 @@ func (m *CLIApp) run() {
|
||||
Aliases: []string{"gen"},
|
||||
Usage: "Generate manifest file",
|
||||
Action: func(c *cli.Context) error {
|
||||
return m.generateManifestOperation(c)
|
||||
return mfa.generateManifestOperation(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
@@ -77,28 +79,40 @@ func (m *CLIApp) run() {
|
||||
Name: "check",
|
||||
Usage: "Validate files using manifest file",
|
||||
Action: func(c *cli.Context) error {
|
||||
return m.validateManifestOperation(c)
|
||||
return mfa.validateManifestOperation(c)
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := m.app.Run(os.Args)
|
||||
err := mfa.app.Run(os.Args)
|
||||
|
||||
if err != nil {
|
||||
m.exitCode = 1
|
||||
mfa.exitCode = 1
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *CLIApp) validateManifestOperation(c *cli.Context) error {
|
||||
func (mfa *CLIApp) validateManifestOperation(c *cli.Context) error {
|
||||
log.Fatal("unimplemented")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CLIApp) generateManifestOperation(c *cli.Context) error {
|
||||
fmt.Println("generateManifest()")
|
||||
fmt.Printf("called with arg: %s", c.String("input"))
|
||||
func (mfa *CLIApp) generateManifestOperation(c *cli.Context) error {
|
||||
fmt.Println("generateManifestOperation()")
|
||||
fmt.Printf("called with arg: %s\n", c.String("input"))
|
||||
|
||||
opts := &mfer.ManifestScanOptions{
|
||||
IgnoreDotfiles: true,
|
||||
FollowSymLinks: false,
|
||||
}
|
||||
mf, err := mfer.NewFromPath(c.String("input"), opts)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
spew.Dump(mf)
|
||||
|
||||
/*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user