1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
pub mod docker;
mod list;
pub mod login;
mod logout;
mod switch;
pub mod types;
mod utils;
use anyhow::Result;
use clap::{Parser, Subcommand};
use crate::state::State;
#[derive(Debug, Subcommand)]
pub enum Commands {
#[clap(name = "ls", alias = "list")]
List(list::Options),
Login(login::Options),
Logout(logout::Options),
Switch(switch::Options),
#[clap(name = "docker", alias = "registry")]
Docker(docker::Options),
}
#[derive(Debug, Parser)]
#[clap(name = "auth", about = "Authenticate with Hop")]
pub struct Options {
#[clap(subcommand)]
pub commands: Commands,
}
pub async fn handle(options: Options, mut state: State) -> Result<()> {
match options.commands {
Commands::Login(options) => login::handle(options, state).await,
Commands::Logout(options) => logout::handle(options, state).await,
Commands::Switch(options) => switch::handle(options, state).await,
Commands::List(options) => {
list::handle(&options, &state);
Ok(())
}
Commands::Docker(options) => docker::handle(&options, &mut state).await,
}
}