main.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package main
  2. import (
  3. "log"
  4. "log/slog"
  5. "os"
  6. "git.andreafazzi.eu/andrea/probo/lib/store/file"
  7. "github.com/urfave/cli/v2"
  8. )
  9. func main() {
  10. _, err := os.Stat(file.DefaultBaseDir)
  11. if err != nil {
  12. slog.Info("Base directory not found. Create the folder structure...")
  13. for _, dir := range file.Dirs {
  14. err := os.MkdirAll(dir, os.ModePerm)
  15. if err != nil {
  16. log.Fatal(err)
  17. }
  18. slog.Info("Create", "directory", dir)
  19. }
  20. slog.Info("Folder structure created without issues.")
  21. os.Exit(0)
  22. }
  23. app := &cli.App{
  24. Name: "probo-cli",
  25. Usage: "Quiz Management System for Hackers!",
  26. Commands: []*cli.Command{
  27. {
  28. Name: "session",
  29. Aliases: []string{"s"},
  30. Usage: "options for command 'session'",
  31. Subcommands: []*cli.Command{
  32. {
  33. Name: "push",
  34. Usage: "Create a new exam session",
  35. Action: push,
  36. },
  37. {
  38. Name: "pull",
  39. Usage: "Download responses from a session",
  40. Action: pull,
  41. },
  42. {
  43. Name: "scores",
  44. Usage: "Show the scores for the given session",
  45. Action: scores,
  46. },
  47. },
  48. },
  49. },
  50. }
  51. if err := app.Run(os.Args); err != nil {
  52. log.Fatal(err)
  53. }
  54. }