pub enum FrameworkCommand {
Serve,
Status,
Service(ServiceCommand),
Update(AppUpdateArgs),
Workspace(WorkspaceCommand),
ApiKey(KeyCommand),
ExternalDevice(LegacyExternalDevice),
Config(AppConfigCommand),
}Expand description
The framework’s commands, flattened into an application’s CLI (spec decision 2).
An application composes these beside its own verbs by giving its subcommand enum a
#[command(flatten)] Framework(FrameworkCommand) variant, so every verb — the app’s and
the framework’s — sits at the same top level. The parse tests below pin that shape.
A desktop app’s binary carries the same enum (#366): it is the CLI as well, so the CLI version is a subset of it. Its subcommand is optional, and with none it opens the window; the CLI version’s is required, so a bare invocation prints the help. The verbs are one definition either way:
#[derive(clap::Parser)]
struct Desktop {
#[command(subcommand)]
command: Option<Command>, // `Command` for the CLI version
}
match Desktop::parse().command {
None => open_the_window(),
Some(command) => runtime.block_on(run(command)),
}Variants§
Serve
Run the server in this process until SIGTERM or SIGINT.
Status
Report whether a server is running, and which version.
Service(ServiceCommand)
Install, remove or report this application’s operating-system service.
Update(AppUpdateArgs)
Replace this executable with the newest release, then do the same for
sapphire-bridge (unless --no-bridge). Restart the services afterwards to run
them.
Workspace(WorkspaceCommand)
Create, select, show and map this application’s workspace. The server serves one at a time.
ApiKey(KeyCommand)
Add, list, retire, restore and rotate the API keys of the workspace this application serves — for clients that reach it over HTTP. Works on the workspace’s files, with or without a running server; the keys sync with the workspace.
ExternalDevice(LegacyExternalDevice)
Renamed to api-key (#364).
Config(AppConfigCommand)
List, show, set and unset this application’s settings and the bridge’s, by key. Without a running server, this application’s own, on its files.
Implementations§
Source§impl FrameworkCommand
impl FrameworkCommand
Sourcepub async fn dispatch<A, F>(
self,
ctx: &'static AppContext,
owner: A,
build: F,
version: &'static str,
) -> Result<i32>
pub async fn dispatch<A, F>( self, ctx: &'static AppContext, owner: A, build: F, version: &'static str, ) -> Result<i32>
Carry out the command, returning the process exit code.
The application matches its own variants first, then hands the framework’s here,
with what serve_restarting takes: its context, its own
settings (() for none) and the function that builds its server from the settings.
serve runs serve_restarting; the commands that need an
AppServer — service, update and mcp — read the settings and call build
once; config reads and writes the settings through the running server, or the
files themselves when none runs.
command
.dispatch(&CTX, MyOwner, |settings: &Settings| AppServer::new(&CTX, VERSION), VERSION)
.awaitTrait Implementations§
Source§impl Debug for FrameworkCommand
impl Debug for FrameworkCommand
Source§impl FromArgMatches for FrameworkCommand
impl FromArgMatches for FrameworkCommand
Source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
Source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches,
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>
Source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§fn update_from_arg_matches_mut<'b>(
&mut self,
__clap_arg_matches: &mut ArgMatches,
) -> Result<(), Error>
fn update_from_arg_matches_mut<'b>( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>
ArgMatches to self.Source§impl Subcommand for FrameworkCommand
impl Subcommand for FrameworkCommand
Source§fn augment_subcommands<'b>(__clap_app: Command) -> Command
fn augment_subcommands<'b>(__clap_app: Command) -> Command
Source§fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
fn augment_subcommands_for_update<'b>(__clap_app: Command) -> Command
Command so it can instantiate self via
FromArgMatches::update_from_arg_matches_mut Read moreSource§fn has_subcommand(__clap_name: &str) -> bool
fn has_subcommand(__clap_name: &str) -> bool
Self can parse a specific subcommandAuto Trait Implementations§
impl Freeze for FrameworkCommand
impl RefUnwindSafe for FrameworkCommand
impl Send for FrameworkCommand
impl Sync for FrameworkCommand
impl Unpin for FrameworkCommand
impl UnsafeUnpin for FrameworkCommand
impl UnwindSafe for FrameworkCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more