add with_about for CLI commands (#2741)

* add with_about for echo, server, and auth

* update for feedback

* finish (most) remaining command documentation

* update comments after additional clarification

* add expanded_api descriptions

* add comments for action_api

* add comments for remaining apis

* add comment for package-rebuild

* fix build errors

* missed one with_about

* add context to git-info subcommands

* remove context from git-info subcommands

* Make git-info from_fns generic over context

* make version::git_info generic over the context

* try removing generics from subcommand and version::git_info

* try adding a closure with context

* Updates for reviewer feedback
This commit is contained in:
Dominion5254
2024-10-16 09:11:32 -06:00
committed by GitHub
parent 0c04802560
commit 9fc082d1e6
31 changed files with 738 additions and 336 deletions

448
core/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,8 @@ pub fn action_api<C: Context>() -> ParentHandler<C> {
"get-input", "get-input",
from_fn_async(get_action_input) from_fn_async(get_action_input)
.with_display_serializable() .with_display_serializable()
.with_call_remote::<CliContext>(), .with_about("Get action input spec")
.with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"run", "run",
@@ -34,7 +35,8 @@ pub fn action_api<C: Context>() -> ParentHandler<C> {
} }
Ok(()) Ok(())
}) })
.with_call_remote::<CliContext>(), .with_about("Run service action")
.with_call_remote::<CliContext>()
) )
} }

View File

@@ -91,28 +91,40 @@ pub fn auth<C: Context>() -> ParentHandler<C> {
.with_metadata("login", Value::Bool(true)) .with_metadata("login", Value::Bool(true))
.no_cli(), .no_cli(),
) )
.subcommand("login", from_fn_async(cli_login).no_display()) .subcommand(
"login",
from_fn_async(cli_login)
.no_display()
.with_about("Log in to StartOS server"),
)
.subcommand( .subcommand(
"logout", "logout",
from_fn_async(logout) from_fn_async(logout)
.with_metadata("get_session", Value::Bool(true)) .with_metadata("get_session", Value::Bool(true))
.no_display() .no_display()
.with_about("Log out of StartOS server")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("session", session::<C>()) .subcommand(
"session",
session::<C>().with_about("List or kill StartOS sessions"),
)
.subcommand( .subcommand(
"reset-password", "reset-password",
from_fn_async(reset_password_impl).no_cli(), from_fn_async(reset_password_impl).no_cli(),
) )
.subcommand( .subcommand(
"reset-password", "reset-password",
from_fn_async(cli_reset_password).no_display(), from_fn_async(cli_reset_password)
.no_display()
.with_about("Reset StartOS password"),
) )
.subcommand( .subcommand(
"get-pubkey", "get-pubkey",
from_fn_async(get_pubkey) from_fn_async(get_pubkey)
.with_metadata("authenticated", Value::Bool(false)) .with_metadata("authenticated", Value::Bool(false))
.no_display() .no_display()
.with_about("Get public key derived from server private key")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }
@@ -290,12 +302,14 @@ pub fn session<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(display_sessions(handle.params, result)) Ok(display_sessions(handle.params, result))
}) })
.with_about("Display all server sessions")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"kill", "kill",
from_fn_async(kill) from_fn_async(kill)
.no_display() .no_display()
.with_about("Terminate existing server session(s)")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -40,9 +40,13 @@ pub fn backup<C: Context>() -> ParentHandler<C> {
"create", "create",
from_fn_async(backup_bulk::backup_all) from_fn_async(backup_bulk::backup_all)
.no_display() .no_display()
.with_about("Create backup for all packages")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("target", target::target::<C>()) .subcommand(
"target",
target::target::<C>().with_about("Commands related to a backup target"),
)
} }
pub fn package_backup<C: Context>() -> ParentHandler<C> { pub fn package_backup<C: Context>() -> ParentHandler<C> {
@@ -50,6 +54,7 @@ pub fn package_backup<C: Context>() -> ParentHandler<C> {
"restore", "restore",
from_fn_async(restore::restore_packages_rpc) from_fn_async(restore::restore_packages_rpc)
.no_display() .no_display()
.with_about("Restore package(s) from backup")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -52,18 +52,21 @@ pub fn cifs<C: Context>() -> ParentHandler<C> {
"add", "add",
from_fn_async(add) from_fn_async(add)
.no_display() .no_display()
.with_about("Add a new backup target")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"update", "update",
from_fn_async(update) from_fn_async(update)
.no_display() .no_display()
.with_about("Update an existing backup target")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"remove", "remove",
from_fn_async(remove) from_fn_async(remove)
.no_display() .no_display()
.with_about("Remove an existing backup target")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -141,11 +141,15 @@ impl FileSystem for BackupTargetFS {
// #[command(subcommands(cifs::cifs, list, info, mount, umount))] // #[command(subcommands(cifs::cifs, list, info, mount, umount))]
pub fn target<C: Context>() -> ParentHandler<C> { pub fn target<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("cifs", cifs::cifs::<C>()) .subcommand(
"cifs",
cifs::cifs::<C>().with_about("Add, remove, or update a backup target"),
)
.subcommand( .subcommand(
"list", "list",
from_fn_async(list) from_fn_async(list)
.with_display_serializable() .with_display_serializable()
.with_about("List existing backup targets")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -155,16 +159,20 @@ pub fn target<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn::<CliContext, _>(|params, info| { .with_custom_display_fn::<CliContext, _>(|params, info| {
Ok(display_backup_info(params.params, info)) Ok(display_backup_info(params.params, info))
}) })
.with_about("Display package backup information")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"mount", "mount",
from_fn_async(mount).with_call_remote::<CliContext>(), from_fn_async(mount)
.with_about("Mount backup target")
.with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"umount", "umount",
from_fn_async(umount) from_fn_async(umount)
.no_display() .no_display()
.with_about("Unmount backup target")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -31,7 +31,12 @@ lazy_static::lazy_static! {
pub fn db<C: Context>() -> ParentHandler<C> { pub fn db<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("dump", from_fn_async(cli_dump).with_display_serializable()) .subcommand(
"dump",
from_fn_async(cli_dump)
.with_display_serializable()
.with_about("Filter/query db to display tables and records"),
)
.subcommand("dump", from_fn_async(dump).no_cli()) .subcommand("dump", from_fn_async(dump).no_cli())
.subcommand( .subcommand(
"subscribe", "subscribe",
@@ -39,8 +44,16 @@ pub fn db<C: Context>() -> ParentHandler<C> {
.with_metadata("get_session", Value::Bool(true)) .with_metadata("get_session", Value::Bool(true))
.no_cli(), .no_cli(),
) )
.subcommand("put", put::<C>()) .subcommand(
.subcommand("apply", from_fn_async(cli_apply).no_display()) "put",
put::<C>().with_about("Command for adding UI record to db"),
)
.subcommand(
"apply",
from_fn_async(cli_apply)
.no_display()
.with_about("Update a db record"),
)
.subcommand("apply", from_fn_async(apply).no_cli()) .subcommand("apply", from_fn_async(apply).no_cli())
} }
@@ -299,6 +312,7 @@ pub fn put<C: Context>() -> ParentHandler<C> {
"ui", "ui",
from_fn_async(ui) from_fn_async(ui)
.with_display_serializable() .with_display_serializable()
.with_about("Add path and value to db")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -13,31 +13,48 @@ use crate::Error;
pub fn diagnostic<C: Context>() -> ParentHandler<C> { pub fn diagnostic<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("error", from_fn(error).with_call_remote::<CliContext>()) .subcommand(
.subcommand("logs", crate::system::logs::<DiagnosticContext>()) "error",
from_fn(error)
.with_about("Display diagnostic error")
.with_call_remote::<CliContext>(),
)
.subcommand( .subcommand(
"logs", "logs",
from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>).no_display(), crate::system::logs::<DiagnosticContext>().with_about("Display OS logs"),
)
.subcommand(
"logs",
from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>)
.no_display()
.with_about("Display OS logs"),
) )
.subcommand( .subcommand(
"kernel-logs", "kernel-logs",
crate::system::kernel_logs::<DiagnosticContext>(), crate::system::kernel_logs::<DiagnosticContext>().with_about("Display kernel logs"),
) )
.subcommand( .subcommand(
"kernel-logs", "kernel-logs",
from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>).no_display(), from_fn_async(crate::logs::cli_logs::<DiagnosticContext, Empty>)
.no_display()
.with_about("Display kernal logs"),
) )
.subcommand( .subcommand(
"restart", "restart",
from_fn(restart) from_fn(restart)
.no_display() .no_display()
.with_about("Restart the server")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("disk", disk::<C>()) .subcommand(
"disk",
disk::<C>().with_about("Command to remove disk from filesystem"),
)
.subcommand( .subcommand(
"rebuild", "rebuild",
from_fn_async(rebuild) from_fn_async(rebuild)
.no_display() .no_display()
.with_about("Teardown and rebuild service containers")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }
@@ -72,7 +89,8 @@ pub fn disk<C: Context>() -> ParentHandler<C> {
CallRemoteHandler::<CliContext, _, _>::new( CallRemoteHandler::<CliContext, _, _>::new(
from_fn_async(forget_disk::<RpcContext>).no_display(), from_fn_async(forget_disk::<RpcContext>).no_display(),
) )
.no_display(), .no_display()
.with_about("Remove disk from filesystem"),
) )
} }

View File

@@ -51,13 +51,16 @@ pub fn disk<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(display_disk_info(handle.params, result)) Ok(display_disk_info(handle.params, result))
}) })
.with_about("List disk info")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("repair", from_fn_async(|_: C| repair()).no_cli()) .subcommand("repair", from_fn_async(|_: C| repair()).no_cli())
.subcommand( .subcommand(
"repair", "repair",
CallRemoteHandler::<CliContext, _, _>::new( CallRemoteHandler::<CliContext, _, _>::new(
from_fn_async(|_: RpcContext| repair()).no_display(), from_fn_async(|_: RpcContext| repair())
.no_display()
.with_about("Repair disk in the event of corruption"),
), ),
) )
} }

View File

@@ -549,18 +549,33 @@ pub async fn init(
pub fn init_api<C: Context>() -> ParentHandler<C> { pub fn init_api<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("logs", crate::system::logs::<InitContext>())
.subcommand( .subcommand(
"logs", "logs",
from_fn_async(crate::logs::cli_logs::<InitContext, Empty>).no_display(), crate::system::logs::<InitContext>().with_about("Disply OS logs"),
)
.subcommand(
"logs",
from_fn_async(crate::logs::cli_logs::<InitContext, Empty>)
.no_display()
.with_about("Display OS logs"),
) )
.subcommand("kernel-logs", crate::system::kernel_logs::<InitContext>())
.subcommand( .subcommand(
"kernel-logs", "kernel-logs",
from_fn_async(crate::logs::cli_logs::<InitContext, Empty>).no_display(), crate::system::kernel_logs::<InitContext>().with_about("Display kernel logs"),
)
.subcommand(
"kernel-logs",
from_fn_async(crate::logs::cli_logs::<InitContext, Empty>)
.no_display()
.with_about("Display kernel logs"),
) )
.subcommand("subscribe", from_fn_async(init_progress).no_cli()) .subcommand("subscribe", from_fn_async(init_progress).no_cli())
.subcommand("subscribe", from_fn_async(cli_init_progress).no_display()) .subcommand(
"subscribe",
from_fn_async(cli_init_progress)
.no_display()
.with_about("Get initialization progress"),
)
} }
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]

View File

@@ -114,29 +114,71 @@ impl std::fmt::Display for ApiState {
pub fn main_api<C: Context>() -> ParentHandler<C> { pub fn main_api<C: Context>() -> ParentHandler<C> {
let api = ParentHandler::new() let api = ParentHandler::new()
.subcommand::<C, _>("git-info", from_fn(version::git_info)) .subcommand(
"git-info",
from_fn(|_: RpcContext| version::git_info())
.with_about("Display the githash of StartOS CLI"),
)
.subcommand( .subcommand(
"echo", "echo",
from_fn(echo::<RpcContext>) from_fn(echo::<RpcContext>)
.with_metadata("authenticated", Value::Bool(false)) .with_metadata("authenticated", Value::Bool(false))
.with_about("Echo a message")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"state", "state",
from_fn(|_: RpcContext| Ok::<_, Error>(ApiState::Running)) from_fn(|_: RpcContext| Ok::<_, Error>(ApiState::Running))
.with_metadata("authenticated", Value::Bool(false)) .with_metadata("authenticated", Value::Bool(false))
.with_about("Display the API that is currently serving")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("server", server::<C>()) .subcommand(
.subcommand("package", package::<C>()) "server",
.subcommand("net", net::net::<C>()) server::<C>()
.subcommand("auth", auth::auth::<C>()) .with_about("Commands related to the server i.e. restart, update, and shutdown"),
.subcommand("db", db::db::<C>()) )
.subcommand("ssh", ssh::ssh::<C>()) .subcommand(
.subcommand("wifi", net::wifi::wifi::<C>()) "package",
.subcommand("disk", disk::disk::<C>()) package::<C>().with_about("Commands related to packages"),
.subcommand("notification", notifications::notification::<C>()) )
.subcommand("backup", backup::backup::<C>()) .subcommand(
"net",
net::net::<C>().with_about("Network commands related to tor and dhcp"),
)
.subcommand(
"auth",
auth::auth::<C>().with_about(
"Commands related to Authentication i.e. login, logout, reset-password",
),
)
.subcommand(
"db",
db::db::<C>().with_about("Commands to interact with the db i.e. dump, put, apply"),
)
.subcommand(
"ssh",
ssh::ssh::<C>()
.with_about("Commands for interacting with ssh keys i.e. add, delete, list"),
)
.subcommand(
"wifi",
net::wifi::wifi::<C>()
.with_about("Commands related to wifi networks i.e. add, connect, delete"),
)
.subcommand(
"disk",
disk::disk::<C>().with_about("Commands for listing disk info and repairing"),
)
.subcommand(
"notification",
notifications::notification::<C>().with_about("Create, delete, or list notifications"),
)
.subcommand(
"backup",
backup::backup::<C>()
.with_about("Commands related to backup creation and backup targets"),
)
.subcommand( .subcommand(
"registry", "registry",
CallRemoteHandler::<RpcContext, _, _, RegistryUrlParams>::new( CallRemoteHandler::<RpcContext, _, _, RegistryUrlParams>::new(
@@ -144,10 +186,20 @@ pub fn main_api<C: Context>() -> ParentHandler<C> {
) )
.no_cli(), .no_cli(),
) )
.subcommand("s9pk", s9pk::rpc::s9pk()) .subcommand(
.subcommand("util", util::rpc::util::<C>()); "s9pk",
s9pk::rpc::s9pk().with_about("Commands for interacting with s9pk files"),
)
.subcommand(
"util",
util::rpc::util::<C>().with_about("Command for calculating the blake3 hash of a file"),
);
#[cfg(feature = "dev")] #[cfg(feature = "dev")]
let api = api.subcommand("lxc", lxc::dev::lxc::<C>()); let api = api.subcommand(
"lxc",
lxc::dev::lxc::<C>()
.with_about("Commands related to lxc containers i.e. create, list, remove, connect"),
);
api api
} }
@@ -160,42 +212,57 @@ pub fn server<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(system::display_time(handle.params, result)) Ok(system::display_time(handle.params, result))
}) })
.with_call_remote::<CliContext>(), .with_about("Display current time and server uptime")
.with_call_remote::<CliContext>()
)
.subcommand(
"experimental",
system::experimental::<C>()
.with_about("Commands related to configuring experimental options such as zram and cpu governor"),
) )
.subcommand("experimental", system::experimental::<C>())
.subcommand("logs", system::logs::<RpcContext>())
.subcommand( .subcommand(
"logs", "logs",
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display(), system::logs::<RpcContext>().with_about("Display OS logs"),
)
.subcommand(
"logs",
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display().with_about("Display OS logs"),
) )
.subcommand("kernel-logs", system::kernel_logs::<RpcContext>())
.subcommand( .subcommand(
"kernel-logs", "kernel-logs",
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display(), system::kernel_logs::<RpcContext>().with_about("Display Kernel logs"),
)
.subcommand(
"kernel-logs",
from_fn_async(logs::cli_logs::<RpcContext, Empty>).no_display().with_about("Display Kernel logs"),
) )
.subcommand( .subcommand(
"metrics", "metrics",
from_fn_async(system::metrics) from_fn_async(system::metrics)
.with_display_serializable() .with_display_serializable()
.with_call_remote::<CliContext>(), .with_about("Display information about the server i.e. temperature, RAM, CPU, and disk usage")
.with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"shutdown", "shutdown",
from_fn_async(shutdown::shutdown) from_fn_async(shutdown::shutdown)
.no_display() .no_display()
.with_call_remote::<CliContext>(), .with_about("Shutdown the server")
.with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"restart", "restart",
from_fn_async(shutdown::restart) from_fn_async(shutdown::restart)
.no_display() .no_display()
.with_call_remote::<CliContext>(), .with_about("Restart the server")
.with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"rebuild", "rebuild",
from_fn_async(shutdown::rebuild) from_fn_async(shutdown::rebuild)
.no_display() .no_display()
.with_call_remote::<CliContext>(), .with_about("Teardown and rebuild service containers")
.with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"update", "update",
@@ -205,7 +272,7 @@ pub fn server<C: Context>() -> ParentHandler<C> {
) )
.subcommand( .subcommand(
"update", "update",
from_fn_async(update::cli_update_system).no_display(), from_fn_async(update::cli_update_system).no_display().with_about("Check a given registry for StartOS updates and update if available"),
) )
.subcommand( .subcommand(
"update-firmware", "update-firmware",
@@ -220,25 +287,31 @@ pub fn server<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|_handle, result| { .with_custom_display_fn(|_handle, result| {
Ok(firmware::display_firmware_update_result(result)) Ok(firmware::display_firmware_update_result(result))
}) })
.with_call_remote::<CliContext>(), .with_about("Update the mainboard's firmware to the latest firmware available in this version of StartOS if available. Note: This command does not reach out to the Internet")
.with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"set-smtp", "set-smtp",
from_fn_async(system::set_system_smtp) from_fn_async(system::set_system_smtp)
.no_display() .no_display()
.with_call_remote::<CliContext>(), .with_about("Set system smtp server and credentials")
.with_call_remote::<CliContext>()
) )
.subcommand( .subcommand(
"clear-smtp", "clear-smtp",
from_fn_async(system::clear_system_smtp) from_fn_async(system::clear_system_smtp)
.no_display() .no_display()
.with_call_remote::<CliContext>(), .with_about("Remove system smtp server and credentials")
.with_call_remote::<CliContext>()
) )
} }
pub fn package<C: Context>() -> ParentHandler<C> { pub fn package<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("action", action::action_api::<C>()) .subcommand(
"action",
action::action_api::<C>().with_about("Commands to get action input or run an action"),
)
.subcommand( .subcommand(
"install", "install",
from_fn_async(install::install) from_fn_async(install::install)
@@ -251,24 +324,32 @@ pub fn package<C: Context>() -> ParentHandler<C> {
.with_metadata("get_session", Value::Bool(true)) .with_metadata("get_session", Value::Bool(true))
.no_cli(), .no_cli(),
) )
.subcommand("install", from_fn_async(install::cli_install).no_display()) .subcommand(
"install",
from_fn_async(install::cli_install)
.no_display()
.with_about("Install a package from a marketplace or via sideloading"),
)
.subcommand( .subcommand(
"uninstall", "uninstall",
from_fn_async(install::uninstall) from_fn_async(install::uninstall)
.with_metadata("sync_db", Value::Bool(true)) .with_metadata("sync_db", Value::Bool(true))
.no_display() .no_display()
.with_about("Remove a package")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"list", "list",
from_fn_async(install::list) from_fn_async(install::list)
.with_display_serializable() .with_display_serializable()
.with_about("List installed packages")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"installed-version", "installed-version",
from_fn_async(install::installed_version) from_fn_async(install::installed_version)
.with_display_serializable() .with_display_serializable()
.with_about("Display installed version for a PackageId")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -276,6 +357,7 @@ pub fn package<C: Context>() -> ParentHandler<C> {
from_fn_async(control::start) from_fn_async(control::start)
.with_metadata("sync_db", Value::Bool(true)) .with_metadata("sync_db", Value::Bool(true))
.no_display() .no_display()
.with_about("Start a package container")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -283,6 +365,7 @@ pub fn package<C: Context>() -> ParentHandler<C> {
from_fn_async(control::stop) from_fn_async(control::stop)
.with_metadata("sync_db", Value::Bool(true)) .with_metadata("sync_db", Value::Bool(true))
.no_display() .no_display()
.with_about("Stop a package container")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -290,6 +373,7 @@ pub fn package<C: Context>() -> ParentHandler<C> {
from_fn_async(control::restart) from_fn_async(control::restart)
.with_metadata("sync_db", Value::Bool(true)) .with_metadata("sync_db", Value::Bool(true))
.no_display() .no_display()
.with_about("Restart a package container")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -297,12 +381,19 @@ pub fn package<C: Context>() -> ParentHandler<C> {
from_fn_async(service::rebuild) from_fn_async(service::rebuild)
.with_metadata("sync_db", Value::Bool(true)) .with_metadata("sync_db", Value::Bool(true))
.no_display() .no_display()
.with_about("Rebuild service container")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("logs", logs::package_logs()) .subcommand("logs", logs::package_logs())
.subcommand( .subcommand(
"logs", "logs",
from_fn_async(logs::cli_logs::<RpcContext, logs::PackageIdParams>).no_display(), logs::package_logs().with_about("Display package logs"),
)
.subcommand(
"logs",
from_fn_async(logs::cli_logs::<RpcContext, logs::PackageIdParams>)
.no_display()
.with_about("Display package logs"),
) )
.subcommand( .subcommand(
"properties", "properties",
@@ -310,13 +401,20 @@ pub fn package<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|_handle, result| { .with_custom_display_fn(|_handle, result| {
Ok(properties::display_properties(result)) Ok(properties::display_properties(result))
}) })
.with_about("Display package Properties")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("backup", backup::package_backup::<C>()) .subcommand(
"backup",
backup::package_backup::<C>()
.with_about("Commands for restoring package(s) from backup"),
)
.subcommand("connect", from_fn_async(service::connect_rpc).no_cli()) .subcommand("connect", from_fn_async(service::connect_rpc).no_cli())
.subcommand( .subcommand(
"connect", "connect",
from_fn_async(service::connect_rpc_cli).no_display(), from_fn_async(service::connect_rpc_cli)
.no_display()
.with_about("Connect to a LXC container"),
) )
.subcommand( .subcommand(
"attach", "attach",
@@ -329,74 +427,124 @@ pub fn package<C: Context>() -> ParentHandler<C> {
pub fn diagnostic_api() -> ParentHandler<DiagnosticContext> { pub fn diagnostic_api() -> ParentHandler<DiagnosticContext> {
ParentHandler::new() ParentHandler::new()
.subcommand::<DiagnosticContext, _>( .subcommand(
"git-info", "git-info",
from_fn(version::git_info).with_metadata("authenticated", Value::Bool(false)), from_fn(|_: DiagnosticContext| version::git_info())
.with_metadata("authenticated", Value::Bool(false))
.with_about("Display the githash of StartOS CLI"),
) )
.subcommand( .subcommand(
"echo", "echo",
from_fn(echo::<DiagnosticContext>).with_call_remote::<CliContext>(), from_fn(echo::<DiagnosticContext>)
.with_about("Echo a message")
.with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"state", "state",
from_fn(|_: DiagnosticContext| Ok::<_, Error>(ApiState::Error)) from_fn(|_: DiagnosticContext| Ok::<_, Error>(ApiState::Error))
.with_metadata("authenticated", Value::Bool(false)) .with_metadata("authenticated", Value::Bool(false))
.with_about("Display the API that is currently serving")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("diagnostic", diagnostic::diagnostic::<DiagnosticContext>()) .subcommand(
"diagnostic",
diagnostic::diagnostic::<DiagnosticContext>()
.with_about("Diagnostic commands i.e. logs, restart, rebuild"),
)
} }
pub fn init_api() -> ParentHandler<InitContext> { pub fn init_api() -> ParentHandler<InitContext> {
ParentHandler::new() ParentHandler::new()
.subcommand::<InitContext, _>( .subcommand(
"git-info", "git-info",
from_fn(version::git_info).with_metadata("authenticated", Value::Bool(false)), from_fn(|_: InitContext| version::git_info())
.with_metadata("authenticated", Value::Bool(false))
.with_about("Display the githash of StartOS CLI"),
) )
.subcommand( .subcommand(
"echo", "echo",
from_fn(echo::<InitContext>).with_call_remote::<CliContext>(), from_fn(echo::<InitContext>)
.with_about("Echo a message")
.with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"state", "state",
from_fn(|_: InitContext| Ok::<_, Error>(ApiState::Initializing)) from_fn(|_: InitContext| Ok::<_, Error>(ApiState::Initializing))
.with_metadata("authenticated", Value::Bool(false)) .with_metadata("authenticated", Value::Bool(false))
.with_about("Display the API that is currently serving")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("init", init::init_api::<InitContext>()) .subcommand(
"init",
init::init_api::<InitContext>()
.with_about("Commands to get logs or initialization progress"),
)
} }
pub fn setup_api() -> ParentHandler<SetupContext> { pub fn setup_api() -> ParentHandler<SetupContext> {
ParentHandler::new() ParentHandler::new()
.subcommand::<SetupContext, _>( .subcommand(
"git-info", "git-info",
from_fn(version::git_info).with_metadata("authenticated", Value::Bool(false)), from_fn(|_: SetupContext| version::git_info())
.with_metadata("authenticated", Value::Bool(false))
.with_about("Display the githash of StartOS CLI"),
) )
.subcommand( .subcommand(
"echo", "echo",
from_fn(echo::<SetupContext>).with_call_remote::<CliContext>(), from_fn(echo::<SetupContext>)
.with_about("Echo a message")
.with_call_remote::<CliContext>(),
) )
.subcommand("setup", setup::setup::<SetupContext>()) .subcommand("setup", setup::setup::<SetupContext>())
} }
pub fn install_api() -> ParentHandler<InstallContext> { pub fn install_api() -> ParentHandler<InstallContext> {
ParentHandler::new() ParentHandler::new()
.subcommand::<InstallContext, _>( .subcommand(
"git-info", "git-info",
from_fn(version::git_info).with_metadata("authenticated", Value::Bool(false)), from_fn(|_: InstallContext| version::git_info())
.with_metadata("authenticated", Value::Bool(false))
.with_about("Display the githash of StartOS CLI"),
) )
.subcommand( .subcommand(
"echo", "echo",
from_fn(echo::<InstallContext>).with_call_remote::<CliContext>(), from_fn(echo::<InstallContext>)
.with_about("Echo a message")
.with_call_remote::<CliContext>(),
)
.subcommand(
"install",
os_install::install::<InstallContext>()
.with_about("Commands to list disk info, install StartOS, and reboot"),
) )
.subcommand("install", os_install::install::<InstallContext>())
} }
pub fn expanded_api() -> ParentHandler<CliContext> { pub fn expanded_api() -> ParentHandler<CliContext> {
main_api() main_api()
.subcommand("init", from_fn_blocking(developer::init).no_display()) .subcommand(
.subcommand("pubkey", from_fn_blocking(developer::pubkey)) "init",
.subcommand("diagnostic", diagnostic::diagnostic::<CliContext>()) from_fn_blocking(developer::init)
.no_display()
.with_about("Create developer key if it doesn't exist"),
)
.subcommand(
"pubkey",
from_fn_blocking(developer::pubkey)
.with_about("Get public key for developer private key"),
)
.subcommand(
"diagnostic",
diagnostic::diagnostic::<CliContext>()
.with_about("Commands to display logs, restart the server, etc"),
)
.subcommand("setup", setup::setup::<CliContext>()) .subcommand("setup", setup::setup::<CliContext>())
.subcommand("install", os_install::install::<CliContext>()) .subcommand(
.subcommand("registry", registry::registry_api::<CliContext>()) "install",
os_install::install::<CliContext>()
.with_about("Commands to list disk info, install StartOS, and reboot"),
)
.subcommand(
"registry",
registry::registry_api::<CliContext>().with_about("Commands related to the registry"),
)
} }

View File

@@ -17,7 +17,9 @@ pub fn lxc<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand( .subcommand(
"create", "create",
from_fn_async(create).with_call_remote::<CliContext>(), from_fn_async(create)
.with_about("Create lxc container")
.with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"list", "list",
@@ -31,16 +33,23 @@ pub fn lxc<C: Context>() -> ParentHandler<C> {
table.printstd(); table.printstd();
Ok(()) Ok(())
}) })
.with_about("List lxc containers")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"remove", "remove",
from_fn_async(remove) from_fn_async(remove)
.no_display() .no_display()
.with_about("Remove lxc container")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("connect", from_fn_async(connect_rpc).no_cli()) .subcommand("connect", from_fn_async(connect_rpc).no_cli())
.subcommand("connect", from_fn_async(connect_rpc_cli).no_display()) .subcommand(
"connect",
from_fn_async(connect_rpc_cli)
.no_display()
.with_about("Connect to a lxc container"),
)
} }
pub async fn create(ctx: RpcContext) -> Result<ContainerId, Error> { pub async fn create(ctx: RpcContext) -> Result<ContainerId, Error> {

View File

@@ -58,6 +58,7 @@ pub fn dhcp<C: Context>() -> ParentHandler<C> {
"update", "update",
from_fn_async::<_, _, (), Error, (RpcContext, UpdateParams)>(update) from_fn_async::<_, _, (), Error, (RpcContext, UpdateParams)>(update)
.no_display() .no_display()
.with_about("Update IP assigned by dhcp")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -1,4 +1,4 @@
use rpc_toolkit::{Context, ParentHandler}; use rpc_toolkit::{Context, HandlerExt, ParentHandler};
pub mod dhcp; pub mod dhcp;
pub mod dns; pub mod dns;
@@ -20,6 +20,12 @@ pub const PACKAGE_CERT_PATH: &str = "/var/lib/embassy/ssl";
pub fn net<C: Context>() -> ParentHandler<C> { pub fn net<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("tor", tor::tor::<C>()) .subcommand(
.subcommand("dhcp", dhcp::dhcp::<C>()) "tor",
tor::tor::<C>().with_about("Tor commands such as list-services, logs, and reset"),
)
.subcommand(
"dhcp",
dhcp::dhcp::<C>().with_about("Command to update IP assigned from dhcp"),
)
} }

View File

@@ -91,17 +91,21 @@ pub fn tor<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(display_services(handle.params, result)) Ok(display_services(handle.params, result))
}) })
.with_about("Display Tor V3 Onion Addresses")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("logs", logs()) .subcommand("logs", logs().with_about("Display Tor logs"))
.subcommand( .subcommand(
"logs", "logs",
from_fn_async(crate::logs::cli_logs::<RpcContext, Empty>).no_display(), from_fn_async(crate::logs::cli_logs::<RpcContext, Empty>)
.no_display()
.with_about("Display Tor logs"),
) )
.subcommand( .subcommand(
"reset", "reset",
from_fn_async(reset) from_fn_async(reset)
.no_display() .no_display()
.with_about("Reset Tor daemon")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -43,18 +43,21 @@ pub fn wifi<C: Context>() -> ParentHandler<C> {
"add", "add",
from_fn_async(add) from_fn_async(add)
.no_display() .no_display()
.with_about("Add wifi ssid and password")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"connect", "connect",
from_fn_async(connect) from_fn_async(connect)
.no_display() .no_display()
.with_about("Connect to wifi network")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"delete", "delete",
from_fn_async(delete) from_fn_async(delete)
.no_display() .no_display()
.with_about("Remove a wifi network")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -64,10 +67,17 @@ pub fn wifi<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(display_wifi_info(handle.params, result)) Ok(display_wifi_info(handle.params, result))
}) })
.with_about("List wifi info")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("country", country::<C>()) .subcommand(
.subcommand("available", available::<C>()) "country",
country::<C>().with_about("Command to set country"),
)
.subcommand(
"available",
available::<C>().with_about("Command to list available wifi networks"),
)
} }
pub fn available<C: Context>() -> ParentHandler<C> { pub fn available<C: Context>() -> ParentHandler<C> {
@@ -76,6 +86,7 @@ pub fn available<C: Context>() -> ParentHandler<C> {
from_fn_async(get_available) from_fn_async(get_available)
.with_display_serializable() .with_display_serializable()
.with_custom_display_fn(|handle, result| Ok(display_wifi_list(handle.params, result))) .with_custom_display_fn(|handle, result| Ok(display_wifi_list(handle.params, result)))
.with_about("List available wifi networks")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }
@@ -85,6 +96,7 @@ pub fn country<C: Context>() -> ParentHandler<C> {
"set", "set",
from_fn_async(set_country) from_fn_async(set_country)
.no_display() .no_display()
.with_about("Set Country")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -26,24 +26,28 @@ pub fn notification<C: Context>() -> ParentHandler<C> {
"list", "list",
from_fn_async(list) from_fn_async(list)
.with_display_serializable() .with_display_serializable()
.with_about("List notifications")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"delete", "delete",
from_fn_async(delete) from_fn_async(delete)
.no_display() .no_display()
.with_about("Delete notification for a given id")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"delete-before", "delete-before",
from_fn_async(delete_before) from_fn_async(delete_before)
.no_display() .no_display()
.with_about("Delete notifications preceding a given id")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"create", "create",
from_fn_async(create) from_fn_async(create)
.no_display() .no_display()
.with_about("Persist a newly created notification")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -31,17 +31,19 @@ mod mbr;
pub fn install<C: Context>() -> ParentHandler<C> { pub fn install<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("disk", disk::<C>()) .subcommand("disk", disk::<C>().with_about("Command to list disk info"))
.subcommand( .subcommand(
"execute", "execute",
from_fn_async(execute::<InstallContext>) from_fn_async(execute::<InstallContext>)
.no_display() .no_display()
.with_about("Install StartOS over existing version")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"reboot", "reboot",
from_fn_async(reboot) from_fn_async(reboot)
.no_display() .no_display()
.with_about("Restart the server")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }
@@ -51,6 +53,7 @@ pub fn disk<C: Context>() -> ParentHandler<C> {
"list", "list",
from_fn_async(list) from_fn_async(list)
.no_display() .no_display()
.with_about("List disk info")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -18,14 +18,23 @@ use crate::util::serde::{display_serializable, HandlerExtSerde, WithIoFormat};
pub fn admin_api<C: Context>() -> ParentHandler<C> { pub fn admin_api<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("signer", signers_api::<C>()) .subcommand(
"signer",
signers_api::<C>().with_about("Commands to add or list signers"),
)
.subcommand("add", from_fn_async(add_admin).no_cli()) .subcommand("add", from_fn_async(add_admin).no_cli())
.subcommand("add", from_fn_async(cli_add_admin).no_display()) .subcommand(
"add",
from_fn_async(cli_add_admin)
.no_display()
.with_about("Add admin signer"),
)
.subcommand( .subcommand(
"list", "list",
from_fn_async(list_admins) from_fn_async(list_admins)
.with_display_serializable() .with_display_serializable()
.with_custom_display_fn(|handle, result| Ok(display_signers(handle.params, result))) .with_custom_display_fn(|handle, result| Ok(display_signers(handle.params, result)))
.with_about("List admin signers")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }
@@ -38,6 +47,7 @@ fn signers_api<C: Context>() -> ParentHandler<C> {
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.with_display_serializable() .with_display_serializable()
.with_custom_display_fn(|handle, result| Ok(display_signers(handle.params, result))) .with_custom_display_fn(|handle, result| Ok(display_signers(handle.params, result)))
.with_about("List signers")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -46,7 +56,10 @@ fn signers_api<C: Context>() -> ParentHandler<C> {
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.no_cli(), .no_cli(),
) )
.subcommand("add", from_fn_async(cli_add_signer)) .subcommand(
"add",
from_fn_async(cli_add_signer).with_about("Add signer"),
)
} }
impl Model<BTreeMap<Guid, SignerInfo>> { impl Model<BTreeMap<Guid, SignerInfo>> {

View File

@@ -18,14 +18,24 @@ use crate::util::serde::{apply_expr, HandlerExtSerde};
pub fn db_api<C: Context>() -> ParentHandler<C> { pub fn db_api<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("dump", from_fn_async(cli_dump).with_display_serializable()) .subcommand(
"dump",
from_fn_async(cli_dump)
.with_display_serializable()
.with_about("Filter/query db to display tables and records"),
)
.subcommand( .subcommand(
"dump", "dump",
from_fn_async(dump) from_fn_async(dump)
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.no_cli(), .no_cli(),
) )
.subcommand("apply", from_fn_async(cli_apply).no_display()) .subcommand(
"apply",
from_fn_async(cli_apply)
.no_display()
.with_about("Update a db record"),
)
.subcommand( .subcommand(
"apply", "apply",
from_fn_async(apply) from_fn_async(apply)

View File

@@ -82,18 +82,32 @@ pub fn registry_api<C: Context>() -> ParentHandler<C> {
"index", "index",
from_fn_async(get_full_index) from_fn_async(get_full_index)
.with_display_serializable() .with_display_serializable()
.with_about("List info including registry name and packages")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"info", "info",
from_fn_async(get_info) from_fn_async(get_info)
.with_display_serializable() .with_display_serializable()
.with_about("Display registry name, icon, and package categories")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("os", os::os_api::<C>()) .subcommand(
.subcommand("package", package::package_api::<C>()) "os",
.subcommand("admin", admin::admin_api::<C>()) os::os_api::<C>().with_about("Commands related to OS assets and versions"),
.subcommand("db", db::db_api::<C>()) )
.subcommand(
"package",
package::package_api::<C>().with_about("Commands to index, add, or get packages"),
)
.subcommand(
"admin",
admin::admin_api::<C>().with_about("Commands to add or list admins or signers"),
)
.subcommand(
"db",
db::db_api::<C>().with_about("Commands to interact with the db i.e. dump and apply"),
)
} }
pub fn registry_router(ctx: RegistryContext) -> Router { pub fn registry_router(ctx: RegistryContext) -> Router {

View File

@@ -26,11 +26,21 @@ use crate::util::io::open_file;
pub fn get_api<C: Context>() -> ParentHandler<C> { pub fn get_api<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("iso", from_fn_async(get_iso).no_cli()) .subcommand("iso", from_fn_async(get_iso).no_cli())
.subcommand("iso", from_fn_async(cli_get_os_asset).no_display()) .subcommand(
"iso",
from_fn_async(cli_get_os_asset)
.no_display()
.with_about("Download iso"),
)
.subcommand("img", from_fn_async(get_img).no_cli()) .subcommand("img", from_fn_async(get_img).no_cli())
.subcommand("img", from_fn_async(cli_get_os_asset).no_display()) .subcommand(
"img",
from_fn_async(cli_get_os_asset)
.no_display()
.with_about("Download img"),
)
.subcommand("squashfs", from_fn_async(get_squashfs).no_cli()) .subcommand("squashfs", from_fn_async(get_squashfs).no_cli())
.subcommand("squashfs", from_fn_async(cli_get_os_asset).no_display()) .subcommand("squashfs", from_fn_async(cli_get_os_asset).no_display().with_about("Download squashfs"))
} }
#[derive(Debug, Deserialize, Serialize, TS)] #[derive(Debug, Deserialize, Serialize, TS)]

View File

@@ -7,8 +7,21 @@ pub mod sign;
pub fn asset_api<C: Context>() -> ParentHandler<C> { pub fn asset_api<C: Context>() -> ParentHandler<C> {
ParentHandler::new() ParentHandler::new()
.subcommand("add", add::add_api::<C>()) .subcommand("add", add::add_api::<C>())
.subcommand("add", from_fn_async(add::cli_add_asset).no_display()) .subcommand(
"add",
from_fn_async(add::cli_add_asset)
.no_display()
.with_about("Add asset to registry"),
)
.subcommand("sign", sign::sign_api::<C>()) .subcommand("sign", sign::sign_api::<C>())
.subcommand("sign", from_fn_async(sign::cli_sign_asset).no_display()) .subcommand(
.subcommand("get", get::get_api::<C>()) "sign",
from_fn_async(sign::cli_sign_asset)
.no_display()
.with_about("Sign file and add to registry index"),
)
.subcommand(
"get",
get::get_api::<C>().with_about("Commands to download image, iso, or squashfs files"),
)
} }

View File

@@ -15,8 +15,16 @@ pub fn os_api<C: Context>() -> ParentHandler<C> {
"index", "index",
from_fn_async(index::get_os_index) from_fn_async(index::get_os_index)
.with_display_serializable() .with_display_serializable()
.with_about("List index of OS versions")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("asset", asset::asset_api::<C>()) .subcommand(
.subcommand("version", version::version_api::<C>()) "asset",
asset::asset_api::<C>().with_about("Commands to add, sign, or get registry assets"),
)
.subcommand(
"version",
version::version_api::<C>()
.with_about("Commands to add, remove, or list versions or version signers"),
)
} }

View File

@@ -26,6 +26,7 @@ pub fn version_api<C: Context>() -> ParentHandler<C> {
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.with_metadata("get_signer", Value::Bool(true)) .with_metadata("get_signer", Value::Bool(true))
.no_display() .no_display()
.with_about("Add OS version")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -33,9 +34,13 @@ pub fn version_api<C: Context>() -> ParentHandler<C> {
from_fn_async(remove_version) from_fn_async(remove_version)
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.no_display() .no_display()
.with_about("Remove OS version")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand("signer", signer::signer_api::<C>()) .subcommand(
"signer",
signer::signer_api::<C>().with_about("Add, remove, and list version signers"),
)
.subcommand( .subcommand(
"get", "get",
from_fn_async(get_version) from_fn_async(get_version)
@@ -43,6 +48,7 @@ pub fn version_api<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(display_version_info(handle.params, result)) Ok(display_version_info(handle.params, result))
}) })
.with_about("Get OS versions and related version info")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -21,6 +21,7 @@ pub fn signer_api<C: Context>() -> ParentHandler<C> {
from_fn_async(add_version_signer) from_fn_async(add_version_signer)
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.no_display() .no_display()
.with_about("Add version signer")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -28,6 +29,7 @@ pub fn signer_api<C: Context>() -> ParentHandler<C> {
from_fn_async(remove_version_signer) from_fn_async(remove_version_signer)
.with_metadata("admin", Value::Bool(true)) .with_metadata("admin", Value::Bool(true))
.no_display() .no_display()
.with_about("Remove version signer")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -35,6 +37,7 @@ pub fn signer_api<C: Context>() -> ParentHandler<C> {
from_fn_async(list_version_signers) from_fn_async(list_version_signers)
.with_display_serializable() .with_display_serializable()
.with_custom_display_fn(|handle, result| Ok(display_signers(handle.params, result))) .with_custom_display_fn(|handle, result| Ok(display_signers(handle.params, result)))
.with_about("List version signers and related signer info")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -14,6 +14,7 @@ pub fn package_api<C: Context>() -> ParentHandler<C> {
"index", "index",
from_fn_async(index::get_package_index) from_fn_async(index::get_package_index)
.with_display_serializable() .with_display_serializable()
.with_about("List packages and categories")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -22,7 +23,12 @@ pub fn package_api<C: Context>() -> ParentHandler<C> {
.with_metadata("get_signer", Value::Bool(true)) .with_metadata("get_signer", Value::Bool(true))
.no_cli(), .no_cli(),
) )
.subcommand("add", from_fn_async(add::cli_add_package).no_display()) .subcommand(
"add",
from_fn_async(add::cli_add_package)
.no_display()
.with_about("Add package to registry index"),
)
.subcommand( .subcommand(
"get", "get",
from_fn_async(get::get_package) from_fn_async(get::get_package)
@@ -31,6 +37,7 @@ pub fn package_api<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
get::display_package_info(handle.params, result) get::display_package_info(handle.params, result)
}) })
.with_about("List installation candidate package(s)")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -21,11 +21,16 @@ pub const SKIP_ENV: &[&str] = &["TERM", "container", "HOME", "HOSTNAME"];
pub fn s9pk() -> ParentHandler<CliContext> { pub fn s9pk() -> ParentHandler<CliContext> {
ParentHandler::new() ParentHandler::new()
.subcommand("pack", from_fn_async(super::v2::pack::pack).no_display()) .subcommand(
"pack",
from_fn_async(super::v2::pack::pack)
.no_display()
.with_about("Package s9pk input files into valid s9pk"),
)
.subcommand( .subcommand(
"list-ingredients", "list-ingredients",
from_fn_async(super::v2::pack::list_ingredients).with_custom_display_fn( from_fn_async(super::v2::pack::list_ingredients)
|_, ingredients| { .with_custom_display_fn(|_, ingredients| {
ingredients ingredients
.into_iter() .into_iter()
.map(Some) .map(Some)
@@ -39,12 +44,23 @@ pub fn s9pk() -> ParentHandler<CliContext> {
}); });
println!(); println!();
Ok(()) Ok(())
}, })
), .with_about("List paths of package ingredients"),
)
.subcommand(
"edit",
edit().with_about("Commands to add an image to an s9pk or edit the manifest"),
)
.subcommand(
"inspect",
inspect().with_about("Commands to display file paths, file contents, or manifest"),
)
.subcommand(
"convert",
from_fn_async(convert)
.no_display()
.with_about("Convert s9pk from v1 to v2"),
) )
.subcommand("edit", edit())
.subcommand("inspect", inspect())
.subcommand("convert", from_fn_async(convert).no_display())
} }
#[derive(Deserialize, Serialize, Parser)] #[derive(Deserialize, Serialize, Parser)]
@@ -59,13 +75,15 @@ fn edit() -> ParentHandler<CliContext, S9pkPath> {
"add-image", "add-image",
from_fn_async(add_image) from_fn_async(add_image)
.with_inherited(only_parent) .with_inherited(only_parent)
.no_display(), .no_display()
.with_about("Add image to s9pk"),
) )
.subcommand( .subcommand(
"manifest", "manifest",
from_fn_async(edit_manifest) from_fn_async(edit_manifest)
.with_inherited(only_parent) .with_inherited(only_parent)
.with_display_serializable(), .with_display_serializable()
.with_about("Edit s9pk manifest"),
) )
} }
@@ -76,17 +94,22 @@ fn inspect() -> ParentHandler<CliContext, S9pkPath> {
"file-tree", "file-tree",
from_fn_async(file_tree) from_fn_async(file_tree)
.with_inherited(only_parent) .with_inherited(only_parent)
.with_display_serializable(), .with_display_serializable()
.with_about("Display list of paths"),
) )
.subcommand( .subcommand(
"cat", "cat",
from_fn_async(cat).with_inherited(only_parent).no_display(), from_fn_async(cat)
.with_inherited(only_parent)
.no_display()
.with_about("Display file contents"),
) )
.subcommand( .subcommand(
"manifest", "manifest",
from_fn_async(inspect_manifest) from_fn_async(inspect_manifest)
.with_inherited(only_parent) .with_inherited(only_parent)
.with_display_serializable(), .with_display_serializable()
.with_about("Display s9pk manifest"),
) )
} }

View File

@@ -86,12 +86,14 @@ pub fn ssh<C: Context>() -> ParentHandler<C> {
"add", "add",
from_fn_async(add) from_fn_async(add)
.no_display() .no_display()
.with_about("Add ssh key")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
"delete", "delete",
from_fn_async(delete) from_fn_async(delete)
.no_display() .no_display()
.with_about("Remove ssh key")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -101,6 +103,7 @@ pub fn ssh<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(display_all_ssh_keys(handle.params, result)) Ok(display_all_ssh_keys(handle.params, result))
}) })
.with_about("List ssh keys")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -31,6 +31,7 @@ pub fn experimental<C: Context>() -> ParentHandler<C> {
"zram", "zram",
from_fn_async(zram) from_fn_async(zram)
.no_display() .no_display()
.with_about("Enable zram")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
.subcommand( .subcommand(
@@ -40,6 +41,7 @@ pub fn experimental<C: Context>() -> ParentHandler<C> {
.with_custom_display_fn(|handle, result| { .with_custom_display_fn(|handle, result| {
Ok(display_governor_info(handle.params, result)) Ok(display_governor_info(handle.params, result))
}) })
.with_about("Show current and available CPU governors")
.with_call_remote::<CliContext>(), .with_call_remote::<CliContext>(),
) )
} }

View File

@@ -1,7 +1,7 @@
use std::path::Path; use std::path::Path;
use clap::Parser; use clap::Parser;
use rpc_toolkit::{from_fn_async, Context, ParentHandler}; use rpc_toolkit::{from_fn_async, Context, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
@@ -16,7 +16,10 @@ use crate::util::{Apply, PathOrUrl};
use crate::CAP_10_MiB; use crate::CAP_10_MiB;
pub fn util<C: Context>() -> ParentHandler<C> { pub fn util<C: Context>() -> ParentHandler<C> {
ParentHandler::new().subcommand("b3sum", from_fn_async(b3sum)) ParentHandler::new().subcommand(
"b3sum",
from_fn_async(b3sum).with_about("Calculate blake3 hash for a file"),
)
} }
#[derive(Debug, Deserialize, Serialize, Parser)] #[derive(Debug, Deserialize, Serialize, Parser)]