2024-03-25 15:53:20 +01:00
|
|
|
/*
|
|
|
|
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
|
|
|
*/
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"git.andreafazzi.eu/andrea/probo/cmd/filter"
|
|
|
|
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
// filterCmd represents the filter command
|
|
|
|
var filterCmd = &cobra.Command{
|
|
|
|
Use: "filter",
|
|
|
|
Short: "Create a new filter",
|
|
|
|
Long: "Create a new filter to select quizzes and participants",
|
|
|
|
Run: createFilter,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
createCmd.AddCommand(filterCmd)
|
|
|
|
|
|
|
|
// Here you will define your flags and configuration settings.
|
|
|
|
|
|
|
|
// Cobra supports Persistent Flags which will work for this command
|
|
|
|
// and all subcommands, e.g.:
|
|
|
|
// filterCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
|
|
|
|
|
|
// Cobra supports local flags which will only run when this command
|
|
|
|
// is called directly, e.g.:
|
|
|
|
// filterCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
|
|
}
|
|
|
|
|
|
|
|
func createFilter(cmd *cobra.Command, args []string) {
|
2024-03-27 11:45:33 +01:00
|
|
|
if len(os.Getenv("DEBUG")) > 0 {
|
|
|
|
f, err := tea.LogToFile("debug.log", "debug")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("fatal:", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
}
|
|
|
|
|
2024-03-25 15:53:20 +01:00
|
|
|
if _, err := tea.NewProgram(filter.New()).Run(); err != nil {
|
|
|
|
fmt.Println("Error running program:", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|