Skip to content

Commit

Permalink
add json output for custom domain
Browse files Browse the repository at this point in the history
  • Loading branch information
alexng353 committed Nov 4, 2024
1 parent e426226 commit 7a58067
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/commands/custom_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Args {
domain: Option<String>,
}

pub async fn command(args: Args, _json: bool) -> Result<()> {
pub async fn command(args: Args, json: bool) -> Result<()> {
// it's too bad that we have to check twice, but I think the UX is better
// if we immediately exit if the user enters an invalid domain
if let Some(domain) = &args.domain {
Expand All @@ -40,7 +40,9 @@ pub async fn command(args: Args, _json: bool) -> Result<()> {

let service = get_service(&linked_project, &project)?;

println!("Creating custom domain for service {}...", service.name);
if !json {
println!("Creating custom domain for service {}...", service.name);
}

let domain = match args.domain {
Some(domain) => domain,
Expand Down Expand Up @@ -81,6 +83,11 @@ pub async fn command(args: Args, _json: bool) -> Result<()> {
post_graphql::<mutations::CustomDomainCreate, _>(&client, configs.get_backboard(), vars)
.await?;

if json {
println!("{}", serde_json::to_string_pretty(&response)?);
return Ok(());
}

println!("Domain created: {}", response.custom_domain_create.domain);

if response.custom_domain_create.status.dns_records.is_empty() {
Expand Down

0 comments on commit 7a58067

Please sign in to comment.