rollup from next branch #4
1
go.mod
1
go.mod
@ -7,5 +7,6 @@ require (
|
|||||||
github.com/pterm/pterm v0.12.35
|
github.com/pterm/pterm v0.12.35
|
||||||
github.com/spf13/afero v1.8.0
|
github.com/spf13/afero v1.8.0
|
||||||
github.com/urfave/cli/v2 v2.3.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
|
google.golang.org/protobuf v1.27.1
|
||||||
)
|
)
|
||||||
|
2
go.sum
2
go.sum
@ -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/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 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
|
||||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
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 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
||||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
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=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/visionmedia/go-cli-log"
|
||||||
|
|
||||||
"git.eeqj.de/sneak/mfer/mfer"
|
"git.eeqj.de/sneak/mfer/mfer"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/pterm/pterm"
|
"github.com/pterm/pterm"
|
||||||
@ -89,12 +91,12 @@ func (mfa *CLIApp) run() {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mfa.exitCode = 1
|
mfa.exitCode = 1
|
||||||
log.Fatal(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mfa *CLIApp) validateManifestOperation(c *cli.Context) error {
|
func (mfa *CLIApp) validateManifestOperation(c *cli.Context) error {
|
||||||
log.Fatal("unimplemented")
|
log.Error(errors.New("unimplemented"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,8 +16,13 @@ type ManifestFile struct {
|
|||||||
FileInfo fs.FileInfo
|
FileInfo fs.FileInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ManifestFile) String() string {
|
||||||
|
return fmt.Sprintf("<File \"%s\">", m.Path)
|
||||||
|
}
|
||||||
|
|
||||||
type Manifest struct {
|
type Manifest struct {
|
||||||
SourceFS afero.Fs
|
SourceFS afero.Fs
|
||||||
|
SourceFSRoot string
|
||||||
Files []*ManifestFile
|
Files []*ManifestFile
|
||||||
ScanOptions *ManifestScanOptions
|
ScanOptions *ManifestScanOptions
|
||||||
TotalFileSize int64
|
TotalFileSize int64
|
||||||
@ -27,11 +34,22 @@ type ManifestScanOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewFromPath(inputPath string, options *ManifestScanOptions) (*Manifest, error) {
|
func NewFromPath(inputPath string, options *ManifestScanOptions) (*Manifest, error) {
|
||||||
afs := afero.NewBasePathFs(afero.NewOsFs(), inputPath)
|
abs, err := filepath.Abs(inputPath)
|
||||||
return NewFromFilesystem(afs, options)
|
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{
|
m := &Manifest{
|
||||||
SourceFS: fs,
|
SourceFS: fs,
|
||||||
ScanOptions: options,
|
ScanOptions: options,
|
||||||
@ -41,7 +59,7 @@ func NewFromFilesystem(fs afero.Fs, options *ManifestScanOptions) (*Manifest, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manifest) Scan() {
|
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, ".") {
|
if m.ScanOptions.IgnoreDotfiles && strings.HasPrefix(path, ".") {
|
||||||
// FIXME make this check all path components BUG
|
// FIXME make this check all path components BUG
|
||||||
@ -54,6 +72,9 @@ func (m *Manifest) Scan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("path = %s\n", path)
|
fmt.Printf("path = %s\n", path)
|
||||||
|
spew.Dump(path)
|
||||||
|
spew.Dump(info)
|
||||||
|
|
||||||
fileinfo, staterr := m.SourceFS.Stat(path)
|
fileinfo, staterr := m.SourceFS.Stat(path)
|
||||||
if staterr != nil {
|
if staterr != nil {
|
||||||
panic(staterr)
|
panic(staterr)
|
||||||
|
Loading…
Reference in New Issue
Block a user