probo/cmd.bk/backup/main.go

82 lines
1.6 KiB
Go
Raw Normal View History

2023-12-21 17:38:05 +01:00
package main
import (
"log"
"log/slog"
"os"
2023-12-27 15:05:11 +01:00
"time"
2023-12-21 17:38:05 +01:00
2024-02-06 09:03:57 +01:00
"git.andreafazzi.eu/andrea/probo/pkg/store/file"
2023-12-27 15:05:11 +01:00
"github.com/lmittmann/tint"
2024-02-06 09:03:57 +01:00
"github.com/urfave/cli"
2023-12-21 17:38:05 +01:00
)
func main() {
2023-12-27 15:05:11 +01:00
slog.SetDefault(slog.New(
tint.NewHandler(os.Stdout, &tint.Options{
Level: slog.LevelInfo,
TimeFormat: time.Kitchen,
}),
))
2023-12-21 17:38:05 +01:00
_, err := os.Stat(file.DefaultBaseDir)
if err != nil {
2023-12-27 15:05:11 +01:00
slog.Info("Base directory not found. Creating the folder structure...")
2023-12-21 17:38:05 +01:00
for _, dir := range file.Dirs {
err := os.MkdirAll(dir, os.ModePerm)
if err != nil {
log.Fatal(err)
}
slog.Info("Create", "directory", dir)
}
slog.Info("Folder structure created without issues.")
os.Exit(0)
}
app := &cli.App{
Name: "probo-cli",
Usage: "Quiz Management System for Hackers!",
Commands: []*cli.Command{
{
Name: "session",
Aliases: []string{"s"},
Usage: "options for command 'session'",
Subcommands: []*cli.Command{
{
Name: "push",
Usage: "Create a new exam session",
Action: push,
},
{
Name: "pull",
Usage: "Download responses from a session",
Action: pull,
},
{
Name: "scores",
Usage: "Show the scores for the given session",
Action: scores,
},
},
},
2023-12-27 15:05:11 +01:00
{
Name: "participant",
Aliases: []string{"p"},
Usage: "options for command 'participant'",
Subcommands: []*cli.Command{
{
Name: "import",
Usage: "Import participants from a CSV file",
Action: importCSV,
},
},
},
2023-12-21 17:38:05 +01:00
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}