🎉 Start project
This commit is contained in:
commit
c711ed6567
7 changed files with 119 additions and 0 deletions
42
cmd/convids/main.go
Normal file
42
cmd/convids/main.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"codeberg.org/danjones000/utils/convids"
|
||||
"codeberg.org/danjones000/utils/internal/cli"
|
||||
"github.com/spf13/pflag"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const dataPath = "shows.yml"
|
||||
|
||||
func main() {
|
||||
loop := pflag.BoolP("loop", "l", false, "Loop")
|
||||
help := pflag.BoolP("help", "h", false, "Get Help")
|
||||
pflag.Parse()
|
||||
|
||||
if *help {
|
||||
pflag.Usage()
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
if *loop {
|
||||
fmt.Println("looping")
|
||||
}
|
||||
|
||||
f, err := os.Open(dataPath)
|
||||
cli.HandleErr(err)
|
||||
|
||||
ydec := yaml.NewDecoder(f)
|
||||
var data convids.Data
|
||||
err = ydec.Decode(&data)
|
||||
cli.HandleErr(err)
|
||||
|
||||
fmt.Printf("Data: %+v\n", data)
|
||||
|
||||
for s := range data.AllShows(false) {
|
||||
fmt.Printf("Show: %+v\n", s)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue