feat: added special case for --profile=all
This commit is contained in:
parent
870107d680
commit
2eee847205
2 changed files with 56 additions and 0 deletions
|
|
@ -136,6 +136,42 @@ func LoadProfileFromFile(path string) (*makeshift.Profile, error) {
|
|||
return loadFromJSONFile[makeshift.Profile](path)
|
||||
}
|
||||
|
||||
func LoadProfilesFromDir(dirpath string) ([]*makeshift.Profile, error) {
|
||||
var (
|
||||
profiles []*makeshift.Profile
|
||||
err error
|
||||
)
|
||||
|
||||
// walk profiles directory to load all profiles
|
||||
err = filepath.Walk(dirpath, func(path string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// skip directories
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// read file contents
|
||||
var profile *makeshift.Profile
|
||||
profile, err = LoadProfileFromFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
profiles = append(profiles, profile)
|
||||
|
||||
fmt.Println(path, info.Size())
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to walk directory '%s': %v", dirpath, err)
|
||||
}
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
// LoadPluginFromFile loads a single plugin given a single file path
|
||||
func LoadPluginFromFile(path string) (makeshift.Plugin, error) {
|
||||
var (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue