mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-18 15:25:45 +00:00
27 lines
541 B
Go
27 lines
541 B
Go
// Copyright 2022 Robert S. Muhlestein.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package comp
|
|
|
|
import (
|
|
"github.com/rwxrob/bonzai/filter"
|
|
"github.com/rwxrob/bonzai/util"
|
|
)
|
|
|
|
// File returns all file names for the directory and file prefix
|
|
// passed. If nothing is passed assumes the current working directory.
|
|
func File(x Command, args ...string) []string {
|
|
match := ""
|
|
dir := "."
|
|
|
|
if len(args) > 0 {
|
|
match = args[0]
|
|
}
|
|
|
|
list := []string{}
|
|
list = append(list, util.Files(dir)...)
|
|
list = filter.HasPrefix(list, match)
|
|
return list
|
|
|
|
}
|