/// Executes the command.
// TODO add client builder insetad of server_url
Executes the command.
TODO add client builder insetad of server_url
Executes the command . TODO add client builder insetad of server_url
pub async fn execute(
        self,
        server_url: Option<Url>,
        pinned_certificate: Option<Certificate>,
        mut cli: Cli,
    ) -> anyhow::Result<()> {
        match self {
            Command::Server(server) => {
                if server_url.is_some() {
                    anyhow::bail!("server url provided for local-only command.")
                }
                server.execute(cli.configuration().await?).await?;
            }
            other => {
                let connection = if let Some(server_url) = server_url {
                    let mut client = Client::build(server_url)
                        .with_custom_api::<<Cli::Backend as Backend>::CustomApi>();
                    if let Some(certificate) = pinned_certificate {
                        client = client.with_certificate(certificate);
                    }
                    AnyServerConnection::Networked(client.finish().await?)
                } else {
                    AnyServerConnection::Local(cli.open_server().await?)
                };
                match other {
                    Command::Admin(admin) => admin.execute(connection).await?,
                    Command::External(external) => {
                        cli.execute(external, connection).await?;
                    }
                    Command::Server(_) => unreachable!(),
                }
            }
        }
        Ok(())
    }
pub async fn execute ( self , server_url : Option < Url > , pinned_certificate : Option < Certificate > , mut cli : Cli , ) -> anyhow :: Result < ( ) > { match self { Command :: Server ( server ) => { if server_url . is_some ( ) { anyhow :: bail ! ( " " ) } server . execute ( cli . configuration ( ) . await ? ) . await ? ; } other => { let connection = if let Some ( server_url ) = server_url { let mut client = Client :: build ( server_url ) . with_custom_api :: < < Cli :: Backend as Backend > :: CustomApi > ( ) ; if let Some ( certificate ) = pinned_certificate { client = client . with_certificate ( certificate ) ; } AnyServerConnection :: Networked ( client . finish ( ) . await ? ) } else { AnyServerConnection :: Local ( cli . open_server ( ) . await ? ) } ; match other { Command :: Admin ( admin ) => admin . execute ( connection ) . await ? , Command :: External ( external ) => { cli . execute ( external , connection ) . await ? ; } Command :: Server ( _ ) => unreachable ! ( ) , } } } Ok ( ( ) ) }
Executes the command.
Executes the command .
self
server_url
Option<Url>
pinned_certificate
Option<Certificate>
cli
Cli