oxyde-cloud-cli 0.4.4

CLI for the Oxyde Cloud
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use anyhow::{Context, Result};
use keyring::Entry;

#[inline(always)]
pub fn api_key_entry() -> Result<Entry> {
    Entry::new("oxyde-cloud", "api-key").context("Failed to create keyring entry for API key")
}

pub fn api_key() -> Result<String> {
    if let Ok(api_key) = std::env::var("OXYDE_CLOUD_API_KEY") {
        Ok(api_key)
    } else {
        api_key_entry()?.get_password().context(
            "Failed to get API key from keyring. Make sure you're logged in with 'oxy login'",
        )
    }
}