small progress
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Jeffrey Paul 2022-12-04 03:18:47 +04:00
parent 0f641db567
commit 295919fbc9
4 changed files with 33 additions and 7 deletions

1
go.mod
View File

@ -7,5 +7,6 @@ require (
github.com/pterm/pterm v0.12.35
github.com/spf13/afero v1.8.0
github.com/urfave/cli/v2 v2.3.0
github.com/visionmedia/go-cli-log v0.0.0-20151214173634-914d1b040b20 // indirect
google.golang.org/protobuf v1.27.1
)

2
go.sum
View File

@ -171,6 +171,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/visionmedia/go-cli-log v0.0.0-20151214173634-914d1b040b20 h1:RDJ3ggSqBL4Mu/ANRKmxuLrwnupJsvHRDXe4/KI+HWE=
github.com/visionmedia/go-cli-log v0.0.0-20151214173634-914d1b040b20/go.mod h1:iljxuLc3m07jsXOWojqehoTp/Fh0XP7irbhV+6sYNGc=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

View File

@ -1,11 +1,13 @@
package cli
import (
"errors"
"fmt"
"log"
"os"
"time"
log "github.com/visionmedia/go-cli-log"
"git.eeqj.de/sneak/mfer/mfer"
"github.com/davecgh/go-spew/spew"
"github.com/pterm/pterm"
@ -89,12 +91,12 @@ func (mfa *CLIApp) run() {
if err != nil {
mfa.exitCode = 1
log.Fatal(err)
log.Error(err)
}
}
func (mfa *CLIApp) validateManifestOperation(c *cli.Context) error {
log.Fatal("unimplemented")
log.Error(errors.New("unimplemented"))
return nil
}

View File

@ -4,8 +4,10 @@ import (
"fmt"
"io"
"io/fs"
"path/filepath"
"strings"
"github.com/davecgh/go-spew/spew"
"github.com/spf13/afero"
)
@ -14,8 +16,13 @@ type ManifestFile struct {
FileInfo fs.FileInfo
}
func (m *ManifestFile) String() string {
return fmt.Sprintf("<File \"%s\">", m.Path)
}
type Manifest struct {
SourceFS afero.Fs
SourceFSRoot string
Files []*ManifestFile
ScanOptions *ManifestScanOptions
TotalFileSize int64
@ -27,11 +34,22 @@ type ManifestScanOptions struct {
}
func NewFromPath(inputPath string, options *ManifestScanOptions) (*Manifest, error) {
afs := afero.NewBasePathFs(afero.NewOsFs(), inputPath)
return NewFromFilesystem(afs, options)
abs, err := filepath.Abs(inputPath)
if err != nil {
return nil, err
}
afs := afero.NewBasePathFs(afero.NewOsFs(), abs)
spew.Dump(afs)
m, err := NewFromFS(afs, options)
if err != nil {
return nil, err
}
m.SourceFSRoot = abs
spew.Dump(m)
return m, nil
}
func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, error) {
func NewFromFS(fs afero.Fs, options *ManifestScanOptions) (*Manifest, error) {
m := &Manifest{
SourceFS: fs,
ScanOptions: options,
@ -41,7 +59,7 @@ func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, er
}
func (m *Manifest) Scan() {
afero.Walk(m.SourceFS, "", func(path string, info fs.FileInfo, err error) error {
afero.Walk(m.SourceFS, "./", func(path string, info fs.FileInfo, err error) error {
if m.ScanOptions.IgnoreDotfiles && strings.HasPrefix(path, ".") {
// FIXME make this check all path components BUG
@ -54,6 +72,9 @@ func (m *Manifest) Scan() {
}
fmt.Printf("path = %s\n", path)
spew.Dump(path)
spew.Dump(info)
fileinfo, staterr := m.SourceFS.Stat(path)
if staterr != nil {
panic(staterr)