participants.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright © 2024 NAME HERE <EMAIL ADDRESS>
  3. */
  4. package cmd
  5. import (
  6. "git.andreafazzi.eu/andrea/probo/pkg/store/file"
  7. "github.com/spf13/cobra"
  8. )
  9. // participantsCmd represents the participants command
  10. var participantsCmd = &cobra.Command{
  11. Use: "participants",
  12. Short: "A brief description of your command",
  13. Long: `A longer description that spans multiple lines and likely contains examples
  14. and usage of using your command. For example:
  15. Cobra is a CLI library for Go that empowers applications.
  16. This application is a tool to generate the needed files
  17. to quickly create a Cobra application.`,
  18. Run: func(cmd *cobra.Command, args []string) {
  19. importCSV(cmd, args)
  20. },
  21. }
  22. func init() {
  23. importCmd.AddCommand(participantsCmd)
  24. // Here you will define your flags and configuration settings.
  25. // Cobra supports Persistent Flags which will work for this command
  26. // and all subcommands, e.g.:
  27. // participantsCmd.PersistentFlags().String("foo", "", "A help for foo")
  28. // Cobra supports local flags which will only run when this command
  29. // is called directly, e.g.:
  30. // participantsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
  31. }
  32. func importCSV(cmd *cobra.Command, args []string) {
  33. pStore, err := file.NewDefaultParticipantFileStore()
  34. if err != nil {
  35. panic(err)
  36. }
  37. _, err = pStore.ImportCSV(args[0])
  38. if err != nil {
  39. panic(err)
  40. }
  41. }