81 lines
1.6 KiB
Go
81 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"log/slog"
|
|
"os"
|
|
"time"
|
|
|
|
"git.andreafazzi.eu/andrea/probo/pkg/store/file"
|
|
"github.com/lmittmann/tint"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
func main() {
|
|
slog.SetDefault(slog.New(
|
|
tint.NewHandler(os.Stdout, &tint.Options{
|
|
Level: slog.LevelInfo,
|
|
TimeFormat: time.Kitchen,
|
|
}),
|
|
))
|
|
|
|
_, err := os.Stat(file.DefaultBaseDir)
|
|
if err != nil {
|
|
slog.Info("Base directory not found. Creating the folder structure...")
|
|
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,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "participant",
|
|
Aliases: []string{"p"},
|
|
Usage: "options for command 'participant'",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "import",
|
|
Usage: "Import participants from a CSV file",
|
|
Action: importCSV,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|