pkar.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/lua
  2. local cli = require "cli"
  3. local plpath = require "pl.path"
  4. local pkar = require "pocket_archive"
  5. local sub = require "pocket_archive.submission"
  6. local hgen = require "pocket_archive.html_generator"
  7. cli.locale "en_US"
  8. init = cli.command {
  9. "Initialize a new Pocket Archive store.",
  10. cli.flag "wipe" {
  11. "Wipe all preexisting data.",
  12. type = cli.boolean,
  13. },
  14. function(args)
  15. if args.wipe then _ = pkar.reset_store
  16. else _ = pkar.store end
  17. _ = nil
  18. collectgarbage()
  19. end
  20. }
  21. submit = cli.command {
  22. "Submit a package.",
  23. cli.positional "path" {
  24. [[Path of the package root. It must be a directory containing
  25. all the files and folders to be submitted and a `pkar_submission.csv`
  26. file at the top of the folder.]]
  27. },
  28. function(args)
  29. sip = sub.generate_sip(plpath.join(args.path, "pkar_submission.csv"))
  30. sub.deposit(sip)
  31. end
  32. }
  33. generate = cli.command {
  34. "Generate a static site from the archive.",
  35. function(args) hgen.generate_site() end
  36. }
  37. cli.program {
  38. "Pocket Archive command line interface.",
  39. }