Skip to content

Commit

Permalink
Merge pull request #486 from DefangLabs/edw-multi-sample
Browse files Browse the repository at this point in the history
Create subfolder for each sample when multiple samples are requested
  • Loading branch information
lionello authored Jun 20, 2024
2 parents 640ee0e + 3ac0fad commit f561327
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pkg/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ func InitFromSamples(ctx context.Context, dir string, names []string) error {
}

for _, name := range names {
// Create a subdirectory for each sample when there is more than one sample requested
subdir := ""
if len(names) > 1 {
subdir = name
}
prefix := fmt.Sprintf("%s-%s/samples/%s/", repo, branch, name)
if base, ok := strings.CutPrefix(h.Name, prefix); ok && len(base) > 0 {
fmt.Println(" -", base)
path := filepath.Join(dir, base)
path := filepath.Join(dir, subdir, base)
if h.FileInfo().IsDir() {
if err := os.MkdirAll(path, 0755); err != nil {
return err
Expand Down

0 comments on commit f561327

Please sign in to comment.