2023-05-23 18:53:53 +00:00
|
|
|
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-06-13 18:47:05 +00:00
|
|
|
import { userAdd } from "./cmd/user_add.ts";
|
|
|
|
import { userPasswd } from "./cmd/user_passwd.ts";
|
|
|
|
import { userDelete } from "./cmd/user_delete.ts";
|
|
|
|
import { userChgrp } from "./cmd/user_chgrp.ts";
|
2023-08-04 16:56:55 +00:00
|
|
|
import { plugRunCommand } from "./cmd/plug_run.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
|
2023-05-24 03:42:02 +00:00
|
|
|
.arguments("[folder:string]")
|
2023-05-23 18:53:53 +00:00
|
|
|
.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
|
|
|
)
|
2023-06-13 18:47:05 +00:00
|
|
|
.option(
|
|
|
|
"--auth <auth.json:string>",
|
|
|
|
"User authentication file to use for authentication",
|
|
|
|
)
|
2023-05-23 18:53:53 +00:00
|
|
|
.option(
|
|
|
|
"--cert <certFile:string>",
|
|
|
|
"Path to TLS certificate",
|
|
|
|
)
|
|
|
|
.option(
|
|
|
|
"--key <keyFile:string>",
|
|
|
|
"Path to TLS key",
|
|
|
|
)
|
|
|
|
.option(
|
2023-08-26 06:31:51 +00:00
|
|
|
"-t [type:boolean], --thin-client [type:boolean]",
|
|
|
|
"Enable thin-client mode",
|
|
|
|
)
|
|
|
|
.option(
|
|
|
|
"--reindex [type:boolean]",
|
|
|
|
"Reindex space on startup (applies to thin-mode only)",
|
|
|
|
)
|
|
|
|
.option(
|
|
|
|
"--db <db:string>",
|
|
|
|
"Path to database file (applies to thin-mode only)",
|
2023-05-23 18:53:53 +00:00
|
|
|
)
|
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")
|
2022-10-24 14:06:36 +00:00
|
|
|
.arguments("<...name.plug.yaml:string>")
|
2022-11-01 14:00:37 +00:00
|
|
|
.option("--debug [type:boolean]", "Do not minifiy code", { default: false })
|
|
|
|
.option("--info [type:boolean]", "Print out size info per function", {
|
|
|
|
default: false,
|
|
|
|
})
|
2022-10-24 14:06:36 +00:00
|
|
|
.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")
|
2023-05-23 18:53:53 +00:00
|
|
|
.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]")
|
2023-08-04 16:56:55 +00:00
|
|
|
.option("--noIndex [type:boolean]", "Do not run a full space index first", {
|
|
|
|
default: false,
|
|
|
|
})
|
2023-08-11 18:37:13 +00:00
|
|
|
.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)
|
2023-06-13 18:47:05 +00:00
|
|
|
.command("user:add", "Add a new user to an authentication file")
|
|
|
|
.arguments("[username:string]")
|
|
|
|
.option(
|
|
|
|
"--auth <auth.json:string>",
|
|
|
|
"User authentication file to use",
|
|
|
|
)
|
|
|
|
.option("-G, --group <name:string>", "Add user to group", {
|
|
|
|
collect: true,
|
|
|
|
default: [] as string[],
|
|
|
|
})
|
|
|
|
.action(userAdd)
|
|
|
|
.command("user:delete", "Delete an existing user")
|
|
|
|
.arguments("[username:string]")
|
|
|
|
.option(
|
|
|
|
"--auth <auth.json:string>",
|
|
|
|
"User authentication file to use",
|
|
|
|
)
|
|
|
|
.action(userDelete)
|
|
|
|
.command("user:chgrp", "Update user groups")
|
|
|
|
.arguments("[username:string]")
|
|
|
|
.option(
|
|
|
|
"--auth <auth.json:string>",
|
|
|
|
"User authentication file to use",
|
|
|
|
)
|
|
|
|
.option("-G, --group <name:string>", "Groups to put user into", {
|
|
|
|
collect: true,
|
|
|
|
default: [] as string[],
|
|
|
|
})
|
|
|
|
.action(userChgrp)
|
|
|
|
.command("user:passwd", "Set the password for an existing user")
|
|
|
|
.arguments("[username:string]")
|
|
|
|
.option(
|
|
|
|
"--auth <auth.json:string>",
|
|
|
|
"User authentication file to use",
|
|
|
|
)
|
|
|
|
.action(userPasswd)
|
2022-10-24 14:06:36 +00:00
|
|
|
// upgrade
|
2023-01-16 15:45:55 +00:00
|
|
|
.command("upgrade", "Upgrade SilverBullet")
|
2022-10-24 11:51:26 +00:00
|
|
|
.action(upgradeCommand)
|
2022-10-24 14:06:36 +00:00
|
|
|
// version
|
2022-10-24 11:51:26 +00:00
|
|
|
.command("version", "Get current version")
|
|
|
|
.action(versionCommand)
|
|
|
|
.parse(Deno.args);
|
2023-08-21 11:56:55 +00:00
|
|
|
Deno.exit(0);
|