Skip to content

Commit

Permalink
Merge pull request #4968 from wasmerio/cli-auth-command
Browse files Browse the repository at this point in the history
CLI: Introduce new `auth` subcommand
  • Loading branch information
xdoardo authored Jul 31, 2024
2 parents 8b41780 + a3f8bb4 commit f55ac06
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
25 changes: 25 additions & 0 deletions lib/cli/src/commands/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
mod login;
mod logout;
mod whoami;

pub use login::*;
pub use logout::*;
pub use whoami::*;

use super::AsyncCliCommand;

/// Manage your .
#[derive(clap::Subcommand, Debug)]
pub enum CmdAuth {
Login(login::Login),
Logout(logout::Logout),
Whoami(whoami::Whoami),
}

#[async_trait::async_trait]
impl AsyncCliCommand for CmdAuth {
type Output = ();

async fn run_async(self) -> Result<Self::Output, anyhow::Error> {
match self {
CmdAuth::Login(l) => l.run_async().await,
CmdAuth::Logout(l) => l.run_async().await,
CmdAuth::Whoami(w) => w.run_async().await,
}
}
}
File renamed without changes.
9 changes: 4 additions & 5 deletions lib/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub mod ssh;
mod validate;
#[cfg(feature = "wast")]
mod wast;
mod whoami;
use std::env::args;
use tokio::task::JoinHandle;

Expand All @@ -51,7 +50,7 @@ pub use {create_obj::*, gen_c_header::*};
pub use self::journal::*;
pub use self::{
add::*, auth::*, cache::*, config::*, container::*, init::*, inspect::*, package::*,
publish::*, run::Run, self_update::*, validate::*, whoami::*,
publish::*, run::Run, self_update::*, validate::*,
};
use crate::error::PrettyError;

Expand Down Expand Up @@ -186,7 +185,7 @@ impl WasmerCmd {
Some(Cmd::Inspect(inspect)) => inspect.execute(),
Some(Cmd::Init(init)) => init.execute(),
Some(Cmd::Login(login)) => login.run(),
Some(Cmd::Logout(logout)) => logout.run(),
Some(Cmd::Auth(auth)) => auth.run(),
Some(Cmd::Publish(publish)) => publish.run().map(|_| ()),
Some(Cmd::Package(cmd)) => match cmd {
Package::Download(cmd) => cmd.execute(),
Expand Down Expand Up @@ -290,8 +289,8 @@ enum Cmd {
/// Login into a wasmer.io-like registry
Login(Login),

/// Log out of the currently selected wasmer.io-like registry
Logout(Logout),
#[clap(subcommand)]
Auth(CmdAuth),

/// Publish a package to a registry [alias: package publish]
#[clap(name = "publish")]
Expand Down

0 comments on commit f55ac06

Please sign in to comment.