Skip to content

Commit

Permalink
bex: Add status command
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jun 26, 2022
1 parent 39f8fb2 commit 6016cb5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bex/crates/bex/src/main.rs
Expand Up @@ -135,6 +135,7 @@ enum Commands {
consumer_key: Option<String>,
},
Logout,
Status,
}

#[tokio::main]
Expand All @@ -146,6 +147,7 @@ async fn main() -> anyhow::Result<()> {
Commands::List { count, tag } => list(count, tag).await?,
Commands::Login { consumer_key } => login(consumer_key).await?,
Commands::Logout => logout().await?,
Commands::Status => status().await?,
}
Ok(())
}
Expand Down Expand Up @@ -248,3 +250,14 @@ async fn logout() -> anyhow::Result<()> {
println!("Logged out");
Ok(())
}

async fn status() -> anyhow::Result<()> {
let state_dir = state_dir()?;
let credential_store = CredentialStore::new(state_dir.as_path());
let credential = credential_store.load()?;
match credential {
Some(credential) => println!("Logged into {}", credential.consumer_key),
None => println!("Not logged in"),
}
Ok(())
}

0 comments on commit 6016cb5

Please sign in to comment.