hive-forge: dedup the --json refusal into refuse_json(), test it, cover attachment-get/artifact-get too
This commit is contained in:
parent
e0ad3a567b
commit
e18497bb70
8 changed files with 58 additions and 27 deletions
|
|
@ -14,6 +14,7 @@ use anyhow::{Result, bail};
|
|||
use clap::Args as ClapArgs;
|
||||
|
||||
use crate::client::Client;
|
||||
use crate::verbs::refuse_json;
|
||||
|
||||
#[derive(ClapArgs)]
|
||||
pub struct Args {
|
||||
|
|
@ -34,6 +35,11 @@ pub struct Args {
|
|||
/// the input, if the download fails (network, 4xx/5xx), or if the
|
||||
/// output path cannot be written.
|
||||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
refuse_json(
|
||||
client.json_mode(),
|
||||
"attachment-get",
|
||||
"it downloads the raw attachment bytes, there is no JSON form",
|
||||
)?;
|
||||
let uuid = extract_uuid(&args.attachment)?;
|
||||
let url = client.attachment_url(&uuid);
|
||||
let bytes = client.get_bytes_raw(&url)?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue