Co-authored-by: sneak <sneak@sneak.berlin> Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
@@ -1,36 +1,54 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"path/filepath"
|
||||
|
||||
"git.eeqj.de/sneak/mfer/internal/log"
|
||||
"git.eeqj.de/sneak/mfer/mfer"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func (mfa *CLIApp) generateManifestOperation(c *cli.Context) error {
|
||||
fmt.Println("generateManifestOperation()")
|
||||
myArgs := c.Args()
|
||||
spew.Dump(myArgs)
|
||||
|
||||
fmt.Printf("%#v\n", c.Args().First())
|
||||
if c.Args().Len() > 0 {
|
||||
fmt.Printf("%#v\n", c.Args().Get(1))
|
||||
}
|
||||
|
||||
// fmt.Printf("called with arg: %s\n", c.String("input"))
|
||||
func (mfa *CLIApp) generateManifestOperation(ctx *cli.Context) error {
|
||||
log.Debug("generateManifestOperation()")
|
||||
myArgs := ctx.Args()
|
||||
log.Dump(myArgs)
|
||||
|
||||
opts := &mfer.ManifestScanOptions{
|
||||
IgnoreDotfiles: c.Bool("IgnoreDotfiles"),
|
||||
FollowSymLinks: c.Bool("FollowSymLinks"),
|
||||
IgnoreDotfiles: ctx.Bool("IgnoreDotfiles"),
|
||||
FollowSymLinks: ctx.Bool("FollowSymLinks"),
|
||||
}
|
||||
// FIXME add command flags for ignoring dotfiles and following symlinks
|
||||
mf, err := mfer.NewFromPath(c.String("input"), opts)
|
||||
paths := make([]string, ctx.Args().Len()-1)
|
||||
for i := 0; i < ctx.Args().Len(); i++ {
|
||||
ap, err := filepath.Abs(ctx.Args().Get(i))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Dump(ap)
|
||||
paths = append(paths, ap)
|
||||
}
|
||||
mf, err := mfer.NewFromPaths(opts, paths...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
mf.WithContext(ctx.Context)
|
||||
|
||||
spew.Dump(mf)
|
||||
log.Dump(mf)
|
||||
|
||||
err = mf.Scan()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
err = mf.WriteTo(buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dat := buf.Bytes()
|
||||
|
||||
log.Dump(dat)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user