govote/cmd/show.go

35 lines
596 B
Go
Raw Normal View History

2024-05-12 22:47:24 +00:00
package cmd
import (
"bufio"
"fmt"
"os"
"code.c-base.org/baccenfutter/govote/store"
"github.com/urfave/cli/v2"
)
var showCmd = &cli.Command{
2024-05-13 08:45:38 +00:00
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]
}
2024-05-12 22:47:24 +00:00
2024-05-13 08:45:38 +00:00
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
},
2024-05-12 22:47:24 +00:00
}