36 lines
657 B
Go
36 lines
657 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
type FlagStringArray []string
|
|
|
|
func (array *FlagStringArray) String() string {
|
|
return strings.Join(*array, ", ")
|
|
}
|
|
|
|
func (array *FlagStringArray) Set(s string) error {
|
|
*array = append(*array, s)
|
|
return nil
|
|
}
|
|
|
|
type FileList FlagStringArray
|
|
|
|
func (fileList FileList) Strings() []string {
|
|
return ([]string)(fileList)
|
|
}
|
|
|
|
func (fileList *FileList) String() string {
|
|
return (*FlagStringArray)(fileList).String()
|
|
}
|
|
|
|
func (fileList *FileList) Set(s string) error {
|
|
if _, err := os.Stat(s); os.IsNotExist(err) {
|
|
return fmt.Errorf("file does not exist: %s", s)
|
|
}
|
|
return (*FlagStringArray)(fileList).Set(s)
|
|
}
|