1
0
silverbullet/silverbullet.ts

135 lines
3.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";
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
.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(
"--auth <auth.json:string>",
"User authentication file to use for authentication",
)
.option(
"--cert <certFile:string>",
"Path to TLS certificate",
)
.option(
"--key <keyFile:string>",
"Path to TLS key",
)
.option(
2023-08-30 15:25:54 +00:00
"--store-only",
"Run the server as a pure space (file) store only without any backend processing (this disables 'server mode' in the client)",
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-30 15:25:54 +00:00
.option(
"--db <db:string>",
"Path to database file",
)
2023-08-04 16:56:55 +00:00
.action(plugRunCommand)
.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)
// upgrade
.command("upgrade", "Upgrade SilverBullet")
2022-10-24 11:51:26 +00:00
.action(upgradeCommand)
// version
2022-10-24 11:51:26 +00:00
.command("version", "Get current version")
.action(versionCommand)
.parse(Deno.args);
Deno.exit(0);