probo/cmd/probo-cli/participant.go

32 lines
644 B
Go
Raw Normal View History

2023-12-27 15:05:11 +01:00
package main
import (
"fmt"
"log/slog"
"git.andreafazzi.eu/andrea/probo/lib/store/file"
"github.com/urfave/cli/v2"
)
func importCSV(cCtx *cli.Context) error {
path := cCtx.Args().First()
if path == "" {
return cli.Exit("Path for the CSV file not given.", 1)
}
2024-02-06 08:35:07 +01:00
pStore, err := file.NewDefaultParticipantFileStore()
2023-12-27 15:05:11 +01:00
if err != nil {
return cli.Exit(fmt.Sprintf("An error occurred: %v", err), 1)
}
participants, err := pStore.ImportCSV(path)
if err != nil {
return cli.Exit(fmt.Sprintf("An error occurred: %v", err), 1)
}
slog.Info("Imported participants from csv file", "nParticipants", len(participants))
return nil
}