govote/cmd/show.go
2024-05-13 00:47:24 +02:00

35 lines
636 B
Go

package cmd
import (
"bufio"
"fmt"
"os"
"code.c-base.org/baccenfutter/govote/store"
"github.com/urfave/cli/v2"
)
var showCmd = &cli.Command{
Name: "show",
Usage: "📈 Display a voting",
Action: func(ctx *cli.Context) error {
var r string
if ctx.Args().Len() == 0 {
inputReader := bufio.NewReader(os.Stdin)
r, _ = inputReader.ReadString('\n')
r = r[:len(r)-1]
}
id := ctx.Args().Get(0)
if id == "" {
return fmt.Errorf("Please provide an ID!")
}
voting, err := store.GetVoting(id)
if err != nil {
return err
}
fmt.Println(voting)
return nil
},
}