Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command line autocomplete to the fs commands #1622

Merged
merged 43 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0095d15
Add autocomplete to fs commands
andersrexdb Jul 22, 2024
e8e93fd
Add tests
andersrexdb Jul 24, 2024
300ab07
Lint
andersrexdb Jul 24, 2024
ba64fd3
Fix TestGlobFileset
andersrexdb Jul 24, 2024
5d6a348
Comments
andersrexdb Jul 24, 2024
e3f6a73
Add onlyDirs
andersrexdb Jul 24, 2024
787d563
Add HasWorkspaceClient
andersrexdb Jul 24, 2024
a43b4af
Add file+dir test
andersrexdb Jul 24, 2024
13eb013
PR comments
andersrexdb Jul 25, 2024
3856332
Programmatically add dbfs:/Volumes
andersrexdb Jul 25, 2024
c73c09b
PR feedback
andersrexdb Jul 27, 2024
363bd1d
Client
andersrexdb Jul 29, 2024
0716f31
Comment
andersrexdb Jul 29, 2024
0341e8b
Cleanup
andersrexdb Jul 29, 2024
a42f121
Support .\ local paths with Windows
andersrexdb Aug 2, 2024
6d10776
Handle local Windows paths
andersrexdb Aug 2, 2024
7c010cc
Support both separators on Windows
andersrexdb Aug 2, 2024
e0d2062
Fix test
andersrexdb Aug 2, 2024
d990fe2
Fix test 2
andersrexdb Aug 2, 2024
1868791
PR feedback
andersrexdb Aug 5, 2024
c4a406c
Remove goroutine
andersrexdb Aug 5, 2024
a909d1f
Doc comments
andersrexdb Aug 5, 2024
6091e0d
Use path and filepath for joining paths
andersrexdb Aug 5, 2024
1591896
Use struct for Validate
andersrexdb Aug 5, 2024
84229be
Lowercase validArgs
andersrexdb Aug 6, 2024
058183e
Add integration test
andersrexdb Aug 6, 2024
5df74cf
Fix error
andersrexdb Aug 6, 2024
0803381
DRY up test
andersrexdb Aug 6, 2024
fb90be9
Use fakeFiler in tests
andersrexdb Aug 6, 2024
d802ba7
Remove PrepFakeFiler
andersrexdb Aug 6, 2024
5261a2c
Remove call to current user
andersrexdb Aug 6, 2024
3514151
Add integration test
andersrexdb Aug 6, 2024
2057aad
Put back GetEnvOrSkipTest
andersrexdb Aug 6, 2024
25e4443
PR feedback
andersrexdb Aug 7, 2024
1b168ae
Cleanup
andersrexdb Aug 7, 2024
c2ae3f0
Simplify path.Dir logic
andersrexdb Aug 7, 2024
e5b32fc
Comments
andersrexdb Aug 7, 2024
81775a4
Cleanup
andersrexdb Aug 7, 2024
57ba288
Add windows test
andersrexdb Aug 7, 2024
0eac4e7
PR comments
andersrexdb Aug 9, 2024
6c85d51
Fix TestGlobFileset
andersrexdb Aug 9, 2024
324e4ab
Try again
andersrexdb Aug 9, 2024
354f4b9
Dont use ../filer in test
andersrexdb Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove PrepFakeFiler
  • Loading branch information
andersrexdb committed Aug 6, 2024
commit d802ba771dda7da4342b62522cfebc0b3bce4588
6 changes: 3 additions & 3 deletions cmd/fs/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ func setupTest(t *testing.T) (*validArgs, *cobra.Command, *mocks.MockWorkspaceCl

fakeFilerForPath := func(ctx context.Context, fullPath string) (filer.Filer, string, error) {
fakeFiler := filer.NewFakeFiler(map[string]filer.FakeFileInfo{
"dir": {name: "root", dir: true},
"dir/dirA": {dir: true},
"dir/dirB": {dir: true},
"dir": {FakeName: "root", FakeDir: true},
"dir/dirA": {FakeDir: true},
"dir/dirB": {FakeDir: true},
"dir/fileA": {},
})
return fakeFiler, fullPath, nil
Expand Down
7 changes: 6 additions & 1 deletion libs/completer/completer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ func setupCompleter(t *testing.T, onlyDirs bool) *completer {
// Needed to make type context.valueCtx for mockFilerForPath
ctx = root.SetWorkspaceClient(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient)

fakeFiler := filer.PrepFakeFiler()
fakeFiler := filer.NewFakeFiler(map[string]filer.FakeFileInfo{
"dir": {FakeName: "root", FakeDir: true},
"dir/dirA": {FakeDir: true},
"dir/dirB": {FakeDir: true},
"dir/fileA": {},
})

return New(ctx, fakeFiler, onlyDirs)
}
Expand Down
38 changes: 12 additions & 26 deletions libs/filer/fake_filer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type FakeDirEntry struct {

func (entry FakeDirEntry) Type() fs.FileMode {
typ := fs.ModePerm
if entry.dir {
if entry.FakeDir {
typ |= fs.ModeDir
}
return typ
Expand All @@ -28,30 +28,30 @@ func (entry FakeDirEntry) Info() (fs.FileInfo, error) {
}

type FakeFileInfo struct {
name string
size int64
dir bool
mode fs.FileMode
FakeName string
FakeSize int64
FakeDir bool
FakeMode fs.FileMode
}

func (info FakeFileInfo) Name() string {
return info.name
return info.FakeName
}

func (info FakeFileInfo) Size() int64 {
return info.size
return info.FakeSize
}

func (info FakeFileInfo) Mode() fs.FileMode {
return info.mode
return info.FakeMode
}

func (info FakeFileInfo) ModTime() time.Time {
return time.Now()
}

func (info FakeFileInfo) IsDir() bool {
return info.dir
return info.FakeDir
}

func (info FakeFileInfo) Sys() any {
Expand Down Expand Up @@ -85,7 +85,7 @@ func (f *FakeFiler) ReadDir(ctx context.Context, p string) ([]fs.DirEntry, error
return nil, fs.ErrNotExist
}

if !entry.dir {
if !entry.FakeDir {
return nil, fs.ErrInvalid
}

Expand Down Expand Up @@ -122,26 +122,12 @@ func NewFakeFiler(entries map[string]FakeFileInfo) *FakeFiler {
}

for k, v := range fakeFiler.entries {
if v.name != "" {
if v.FakeName != "" {
continue
}
v.name = path.Base(k)
v.FakeName = path.Base(k)
fakeFiler.entries[k] = v
}

return fakeFiler
}

// TODO: Remove this function
func PrepFakeFiler() *FakeFiler {
return NewFakeFiler(map[string]FakeFileInfo{
"dir": {name: "root", dir: true},
"dir/dirA": {dir: true},
"dir/dirB": {dir: true},
"dir/fileA": {size: 3},
})
}

func NewFakeFileInfo(dir bool) FakeFileInfo {
return FakeFileInfo{dir: dir}
}