1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*
- 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) {
- 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()
- }
- if _, err := tea.NewProgram(filter.New()).Run(); err != nil {
- fmt.Println("Error running program:", err)
- os.Exit(1)
- }
- }
|