Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Mar 5, 2024
1 parent 9d9fa39 commit 205f47a
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions rust/agama-cli/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use clap::Subcommand;
use reqwest::header::{HeaderMap, CONTENT_TYPE, HeaderValue};
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
use std::fs::File;
use std::io;
use std::io::{BufRead, BufReader};
use std::fs::File;
use std::path::{PathBuf};
use std::path::PathBuf;

const DEFAULT_JWT_FILE: &str = "/tmp/agama-jwt";
const DEFAULT_AUTH_URL: &str = "http://localhost:3000/authenticate";
Expand All @@ -12,10 +12,10 @@ const DEFAULT_AUTH_URL: &str = "http://localhost:3000/authenticate";
pub enum ServerCommands {
/// Login with defined server. Result is JWT stored and used in all subsequent commands
Login {
#[clap(long, short = 'p')]
password: Option<String>,
#[clap(long, short = 'f')]
file: Option<PathBuf>,
#[clap(long, short = 'p')]
password: Option<String>,
#[clap(long, short = 'f')]
file: Option<PathBuf>,
},
/// Release currently stored JWT
Logout,
Expand All @@ -24,10 +24,7 @@ pub enum ServerCommands {
/// Main entry point called from agama CLI main loop
pub async fn run(subcommand: ServerCommands) -> anyhow::Result<()> {
match subcommand {
ServerCommands::Login {
password,
file,
}=> {
ServerCommands::Login { password, file } => {
// actions to do:
// 1) somehow obtain credentials (interactive, commandline, from a file)
// credentials are handled in this way (in descending priority)
Expand All @@ -42,12 +39,12 @@ pub async fn run(subcommand: ServerCommands) -> anyhow::Result<()> {
};

login(LoginOptions::parse(options).password()?).await
},
}
ServerCommands::Logout => {
// actions to do:
// 1) release JWT from the well known location if any
logout()
},
}
}
}

Expand Down

0 comments on commit 205f47a

Please sign in to comment.