Skip to content

Commit

Permalink
fix: set variables command and add debug to auth
Browse files Browse the repository at this point in the history
`envx set key=value` now works when the project has no variables (in
this case, it used to break because the helper function decrypt_full_many
would return an error)

`envx auth` now has a `--debug` flag to print the request and response
  • Loading branch information
alexng353 committed Sep 12, 2024
1 parent 54e44ea commit d44b849
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/commands/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ pub struct Args {
/// Key to sign with
#[clap(short, long)]
key: Option<String>,

/// Debug output
#[clap(short, long)]
debug: bool,
}

pub async fn command(args: Args) -> anyhow::Result<()> {
Expand All @@ -30,12 +34,22 @@ pub async fn command(args: Args) -> anyhow::Result<()> {

println!("auth token:\n{}", auth_token.signature);

let url = format!("{}test-auth", get_api_url());

if args.debug {
dbg!(&url);
}

let res = client
.post(format!("{}/test-auth", get_api_url()))
.post(url)
.header(header::AUTHORIZATION, format!("Bearer {}", auth_token))
.send()
.await?;

if args.debug {
dbg!(&res);
}

let status = res.status();

if status.is_success() {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/rpgp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ pub fn decrypt_full_many(
messages: Vec<String>,
config: &Config,
) -> Result<Vec<String>, anyhow::Error> {
let first = messages.first().ok_or_else(|| anyhow!("No messages"))?;
let first = if let Some(first) = messages.first() {
first
} else {
return Ok(vec![]);
};

let msg = Message::from_string(first.as_str())?.0;

let recipients: Vec<String> = msg
Expand Down

0 comments on commit d44b849

Please sign in to comment.