12345678910111213141516171819202122232425262728293031 |
- package main
- import (
- "fmt"
- "log/slog"
- "git.andreafazzi.eu/andrea/probo/pkg/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)
- }
- pStore, err := file.NewDefaultParticipantFileStore()
- 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
- }
|