123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #!/usr/bin/lua
- local cli = require "cli"
- local plpath = require "pl.path"
- local nsm = require "volksdata.namespace"
- local term = require "volksdata.term"
- local triple = require "volksdata.triple"
- local graph = require "volksdata.graph"
- local pkar = require "pocket_archive"
- local sub = require "pocket_archive.submission"
- local hgen = require "pocket_archive.html_generator"
- cli.locale "en_US" -- TODO set with multilingual support.
- init = cli.command {
- "Initialize a new Pocket Archive store.",
- cli.flag "wipe" {
- "Wipe all preexisting data.",
- type = cli.boolean,
- },
- function(args)
- if args.wipe then _ = pkar.reset_store
- else _ = pkar.store end
- end
- }
- list = cli.command {
- "List all resource IDs.",
- function()
- local gr = graph.new(pkar.store, term.DEFAULT_CTX)
- for _, s in pairs(gr:unique_terms(triple.POS_S)) do
- print(nsm.denormalize_uri(s.data))
- end
- end,
- }
- deposit = cli.command {
- "Deposit a package.",
- cli.positional "path" {
- [[Path of the package root. It must be a directory containing
- all the files and folders to be submitted and a `pkar_submission.csv`
- file at the top of the folder.]]
- },
- function(args)
- sip = sub.generate_sip(plpath.join(args.path, "pkar_submission.csv"))
- sub.deposit(sip)
- end
- }
- gen_site = cli.command {
- "Generate a static site from the archive.",
- function(args) hgen.generate_site() end
- }
- gen_rdf = cli.command {
- "Generate an RDF representation of a resource.",
- cli.positional "id" {
- "ID of the resource, prefixed by `par:`",
- type = cli.string,
- },
- cli.flag "f,format" {
- "RDF format. `nt` and `ttl` are available.",
- type = cli.string,
- default = "ttl",
- },
- function(args)
- local s = term.new_iriref_ns(args.id)
- print(hgen.generate_rdf(s, args.format))
- end,
- }
- gen_ll = cli.command {
- "Generate a laundry list for a stored resource.",
- cli.positional "id" {
- "ID of the resource, prefixed by `par:`",
- type = cli.string,
- },
- function(args)
- local s = term.new_iriref_ns(args.id)
- print(hgen.generate_ll(s))
- end
- }
- cli.program {
- "Pocket Archive command line interface.",
- }
|