60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"log/slog"
|
|
"os"
|
|
|
|
"git.andreafazzi.eu/andrea/probo/lib/store/file"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func main() {
|
|
_, err := os.Stat(file.DefaultBaseDir)
|
|
if err != nil {
|
|
slog.Info("Base directory not found. Create 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,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|