1
0
silverbullet/silverbullet.ts

104 lines
2.9 KiB
TypeScript
Raw Normal View History

import.meta.main = false;
2022-10-24 11:51:26 +00:00
import { Command } from "https://deno.land/x/cliffy@v0.25.2/command/command.ts";
import { version } from "./version.ts";
import { upgradeCommand } from "./cmd/upgrade.ts";
import { versionCommand } from "./cmd/version.ts";
import { serveCommand } from "./cmd/server.ts";
2022-11-01 14:00:37 +00:00
import { plugCompileCommand } from "./cmd/plug_compile.ts";
2023-08-04 16:56:55 +00:00
import { plugRunCommand } from "./cmd/plug_run.ts";
import { syncCommand } from "./cmd/sync.ts";
2022-10-24 11:51:26 +00:00
await new Command()
.name("silverbullet")
.description("Markdown as a platform")
.version(version)
.help({
colors: false,
})
.usage("<options> <folder> | <command> (see below)")
// Main command
.arguments("[folder:string]")
.option(
"--hostname, -L <hostname:string>",
"Hostname or address to listen on",
)
2022-10-24 11:51:26 +00:00
.option("-p, --port <port:number>", "Port to listen on")
2022-12-05 11:14:21 +00:00
.option(
"--user <user:string>",
2023-08-20 15:51:00 +00:00
"'username:password' combo for authentication",
2022-12-05 11:14:21 +00:00
)
.option(
"--cert <certFile:string>",
"Path to TLS certificate",
)
.option(
"--key <keyFile:string>",
"Path to TLS key",
)
.option(
2023-09-07 10:38:20 +00:00
"--sync-only",
"Run the server as a pure space (file) store only without any backend processing (this disables 'online mode' in the client)",
2023-08-26 06:31:51 +00:00
)
.option(
"--client-encryption",
"Enable client-side encryption for spaces",
)
2023-08-26 06:31:51 +00:00
.option(
2023-08-30 15:25:54 +00:00
"--reindex",
2023-08-29 19:17:29 +00:00
"Reindex space on startup",
2023-08-26 06:31:51 +00:00
)
.option(
"--db <db:string>",
2023-08-29 19:17:29 +00:00
"Path to database file",
)
2022-10-24 11:51:26 +00:00
.action(serveCommand)
2022-11-01 14:00:37 +00:00
// plug:compile
2022-10-25 16:49:33 +00:00
.command("plug:compile", "Bundle (compile) one or more plug manifests")
.arguments("<...name.plug.yaml:string>")
2023-08-30 15:25:54 +00:00
.option("--debug", "Do not minifiy code", { default: false })
.option("--info", "Print out size info per function", {
2022-11-01 14:00:37 +00:00
default: false,
})
.option("--watch, -w [type:boolean]", "Watch for changes and rebuild", {
default: false,
})
.option(
"--dist <path:string>",
"Folder to put the resulting .plug.json file into",
{ default: "." },
)
.option("--importmap <path:string>", "Path to import map file to use")
.option("--runtimeUrl <url:string>", "URL to worker_runtime.ts to use")
2022-11-01 14:00:37 +00:00
.action(plugCompileCommand)
2023-08-04 16:56:55 +00:00
// plug:run
.command("plug:run", "Run a PlugOS function from the CLI")
2023-08-11 18:37:13 +00:00
.arguments("<spacePath> [function] [...args:string]")
.option(
"--hostname, -L <hostname:string>",
"Hostname or address to listen on",
)
.option("-p, --port <port:number>", "Port to listen on")
2023-08-04 16:56:55 +00:00
.action(plugRunCommand)
// upgrade
.command("upgrade", "Upgrade SilverBullet")
2022-10-24 11:51:26 +00:00
.action(upgradeCommand)
// sync
.command("sync", "Synchronize two spaces")
.option(
"--snapshot <snapshot:string>",
"Path to state file to use",
)
.option(
"--wipe-secondary",
"Wipe secondary and perform a full sync",
)
.arguments("<primary:string> <secondary:string>")
.action(syncCommand)
// version
2022-10-24 11:51:26 +00:00
.command("version", "Get current version")
.action(versionCommand)
.parse(Deno.args);
Deno.exit(0);