feat(globs): glob support extended to ls and documented in README
This commit is contained in:
parent
badbf3b6bb
commit
95c9ac8fca
8 changed files with 316 additions and 74 deletions
28
cmd/glob.go
Normal file
28
cmd/glob.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var defaultGlobSeparators = []rune{'/', '-', '_', '.', '@', ':', ' '}
|
||||
|
||||
func defaultGlobSeparatorsDisplay() string {
|
||||
var b strings.Builder
|
||||
for _, r := range defaultGlobSeparators {
|
||||
b.WriteRune(r)
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func parseGlobSeparators(cmd *cobra.Command) ([]rune, error) {
|
||||
sepStr, err := cmd.Flags().GetString("glob-sep")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if sepStr == "" {
|
||||
return defaultGlobSeparators, nil
|
||||
}
|
||||
return []rune(sepStr), nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue