Skip to content

Commit

Permalink
Merge pull request #54 from chuttam/au/dot-glob
Browse files Browse the repository at this point in the history
`massren .` to rename files in current directory
  • Loading branch information
laurent22 authored Apr 29, 2024
2 parents 7d7e8f5 + 282990c commit b9251ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func filePathsFromArgs(args []string, includeDirectories bool) ([]string, error)
var output []string
var err error

if len(args) == 0 {
if len(args) == 0 || args[0] == "." {
output, err = filepath.Glob("*")
if err != nil {
return []string{}, err
Expand Down
27 changes: 26 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,35 @@ func Test_filePathsFromArgs(t *testing.T) {
t.Error(err)
}

// "." (current directory) as the only file path argument works the same as "*"
currentDir, err := os.Getwd()
if err != nil {
panic(err)
}

err = os.Chdir(tempFolder())
if err != nil {
panic(err)
}

args = []string{"."}

filePaths, err = filePathsFromArgs(args, true)
if err != nil {
t.Fatal(err)
}

err = fileListsAreEqual(filePaths, tempFiles)
if err != nil {
t.Error(err)
}

os.Chdir(currentDir)

// If no argument is provided, the function should default to "*"
// in the current dir.

currentDir, err := os.Getwd()
currentDir, err = os.Getwd()
if err != nil {
panic(err)
}
Expand Down

0 comments on commit b9251ef

Please # to comment.