Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rust/src/actions_catalog/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use cli_engine::{
CommandResult, CommandSpec, GroupSpec, Module, NextAction, NextActionParam, RuntimeCommandSpec,
CommandResult, CommandSpec, GroupSpec, Module, NextActionParam, RuntimeCommandSpec,
RuntimeGroupSpec, Stage, Tier,
};
use serde_json::json;

use crate::next_action::next_action;

/// Static catalog of available GoDaddy action names.
/// Loaded from the manifest at compile time.
const ACTIONS: &[(&str, &str)] = &[
Expand Down Expand Up @@ -87,7 +89,7 @@ pub fn module() -> Module {
.map(|(name, description)| json!({ "name": name, "description": description }))
.collect();
Ok(CommandResult::new(json!({ "actions": actions })).with_next_actions(vec![
NextAction::new("actions describe <action>", "See an action's full schema")
next_action("actions describe <action>", "See an action's full schema")
.with_param("action", NextActionParam::required()),
]))
},
Expand Down
13 changes: 7 additions & 6 deletions rust/src/api_explorer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::sync::OnceLock;

use cli_engine::{
CommandResult, CommandSpec, GroupSpec, Module, NextAction, NextActionParam, RuntimeCommandSpec,
CommandResult, CommandSpec, GroupSpec, Module, NextActionParam, RuntimeCommandSpec,
RuntimeGroupSpec, Tier,
};
use serde::Deserialize;
use serde_json::{Value, json};

use crate::next_action::next_action;
use crate::output_schema::output_schema;

output_schema!(ApiDomain {
Expand Down Expand Up @@ -304,12 +305,12 @@ fn domain_list_command() -> RuntimeCommandSpec {
})
.collect();
Ok(CommandResult::new(json!(domains)).with_next_actions(vec![
NextAction::new(
next_action(
"api endpoint list --domain <domain>",
"List endpoints in a specific domain",
)
.with_param("domain", NextActionParam::required()),
NextAction::new("api search <query>", "Search across all endpoints"),
next_action("api search <query>", "Search across all endpoints"),
]))
},
)
Expand Down Expand Up @@ -362,7 +363,7 @@ fn endpoint_list_command() -> RuntimeCommandSpec {
})
.collect();
Ok(CommandResult::new(json!(endpoints)).with_next_actions(vec![
NextAction::new(
next_action(
"api describe <operationId>",
"Get full details for an endpoint",
)
Expand Down Expand Up @@ -419,7 +420,7 @@ fn describe_command() -> RuntimeCommandSpec {
"scopes": ep.scopes,
}))
.with_next_actions(vec![
NextAction::new(
next_action(
format!("api call {} --method {}", ep.path, ep.method),
"Make an authenticated call to this endpoint",
),
Expand Down Expand Up @@ -467,7 +468,7 @@ fn search_command() -> RuntimeCommandSpec {
})
.collect();
Ok(CommandResult::new(json!(results)).with_next_actions(vec![
NextAction::new(
next_action(
"api describe <operationId>",
"Get full details for a result",
)
Expand Down
39 changes: 20 additions & 19 deletions rust/src/application/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use cli_engine::{
CommandResult, CommandSpec, GroupSpec, NextAction, NextActionParam, RuntimeCommandSpec,
RuntimeGroupSpec, StreamSender, Tier,
CommandResult, CommandSpec, GroupSpec, NextActionParam, RuntimeCommandSpec, RuntimeGroupSpec,
StreamSender, Tier,
};
use serde_json::json;

use crate::application::client::{ApplicationClient, api_url_for_env};
use crate::next_action::next_action;
use crate::output_schema::output_schema;
// App-registry mutations declare their scopes so `apps.app-registry:write` is
// requested on demand (OAuth step-up), not granted at every login — it's a
Expand Down Expand Up @@ -151,12 +152,12 @@ fn list_command() -> RuntimeCommandSpec {
let client = make_client(&ctx).await?;
let data = client.list_applications().await.map_err(client_err)?;
Ok(CommandResult::new(data).with_next_actions(vec![
NextAction::new(
next_action(
"application info --name <name>",
"Get details for a specific application",
)
.with_param("name", NextActionParam::required()),
NextAction::new(
next_action(
"application init --name <name> --description <desc> --url <url>",
"Initialize a new application",
),
Expand Down Expand Up @@ -190,11 +191,11 @@ fn info_command() -> RuntimeCommandSpec {
let data = client.get_application(&name).await.map_err(client_err)?;
Ok(
CommandResult::new(data["application"].clone()).with_next_actions(vec![
NextAction::new(
next_action(
"application release --application-id <id> --version <ver>",
"Create a release",
),
NextAction::new(
next_action(
format!("application deploy --name {name}"),
"Deploy this application",
)
Expand All @@ -206,7 +207,7 @@ fn info_command() -> RuntimeCommandSpec {
..Default::default()
},
),
NextAction::new(
next_action(
"application update --id <id>",
"Update application metadata",
),
Expand Down Expand Up @@ -328,15 +329,15 @@ fn init_command() -> RuntimeCommandSpec {
.map_err(|e| cli_engine::CliCoreError::message(e.to_string()))?;

Ok(CommandResult::new(app.clone()).with_next_actions(vec![
NextAction::new(
next_action(
"application add action --name <name> --url <url>",
"Add an action to godaddy.toml",
),
NextAction::new(
next_action(
"application validate",
"Validate the generated godaddy.toml",
),
NextAction::new(
next_action(
"application release --application-id <id> --version 0.0.1",
"Create the first release",
),
Expand Down Expand Up @@ -434,7 +435,7 @@ fn update_command() -> RuntimeCommandSpec {
.to_owned();
Ok(
CommandResult::new(data["updateApplication"].clone()).with_next_actions(vec![
NextAction::new(
next_action(
format!("application info --name {name}"),
"Inspect updated application",
)
Expand All @@ -446,7 +447,7 @@ fn update_command() -> RuntimeCommandSpec {
..Default::default()
},
),
NextAction::new(
next_action(
format!("application deploy --name {name}"),
"Deploy updated application",
)
Expand Down Expand Up @@ -499,7 +500,7 @@ fn enable_command() -> RuntimeCommandSpec {
.map_err(client_err)?;
Ok(
CommandResult::new(data["enableStoreApplication"].clone()).with_next_actions(vec![
NextAction::new(
next_action(
format!("application disable {name} --store-id {store_id}"),
"Disable the application on the same store",
)
Expand All @@ -519,7 +520,7 @@ fn enable_command() -> RuntimeCommandSpec {
..Default::default()
},
),
NextAction::new(
next_action(
format!("application info --name {name}"),
"Inspect application",
)
Expand Down Expand Up @@ -573,7 +574,7 @@ fn disable_command() -> RuntimeCommandSpec {
Ok(
CommandResult::new(data["disableStoreApplication"].clone()).with_next_actions(
vec![
NextAction::new(
next_action(
format!("application enable {name} --store-id {store_id}"),
"Re-enable the application on the same store",
)
Expand All @@ -593,7 +594,7 @@ fn disable_command() -> RuntimeCommandSpec {
..Default::default()
},
),
NextAction::new(
next_action(
format!("application info --name {name}"),
"Inspect application",
)
Expand Down Expand Up @@ -646,7 +647,7 @@ fn archive_command() -> RuntimeCommandSpec {
.map_err(client_err)?;
Ok(
CommandResult::new(data["archiveApplication"].clone()).with_next_actions(vec![
NextAction::new("application list", "List remaining applications"),
next_action("application list", "List remaining applications"),
]),
)
},
Expand Down Expand Up @@ -702,8 +703,8 @@ fn release_command() -> RuntimeCommandSpec {
let data = client.create_release(input).await.map_err(client_err)?;
Ok(
CommandResult::new(data["createRelease"].clone()).with_next_actions(vec![
NextAction::new("application deploy --name <name>", "Deploy this release"),
NextAction::new("application info --name <name>", "Inspect application"),
next_action("application deploy --name <name>", "Deploy this release"),
next_action("application info --name <name>", "Inspect application"),
]),
)
},
Expand Down
3 changes: 2 additions & 1 deletion rust/src/dns/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use cli_engine::{
use serde_json::{Value, json};

use crate::domain::{api_error, make_client, string_list};
use crate::next_action::next_action;
use crate::output_schema::output_schema;
use crate::scopes::{DOMAINS_DNS_UPDATE, DOMAINS_READ};

Expand Down Expand Up @@ -351,7 +352,7 @@ fn summarize_delete_outcomes(
/// Next action pointing back at `dns list` to verify a write, pre-filled with
/// the domain/type/name the write just touched.
fn verify_with_list_action(domain: &str, record_type: &str, name: &str) -> NextAction {
NextAction::new(
next_action(
"dns list <domain> --type <type> --name <name>",
"Verify the records for this type+name",
)
Expand Down
7 changes: 4 additions & 3 deletions rust/src/domain/agreements.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//! `gddy domain agreements` — the legal agreements a TLD requires (v1).

use cli_engine::{
CommandResult, CommandSpec, NextAction, NextActionParam, RuntimeCommandSpec, TableColumn, Tier,
CommandResult, CommandSpec, NextActionParam, RuntimeCommandSpec, TableColumn, Tier,
};
use serde_json::json;

use domains_client::types;

use super::common::{api_error, make_client, string_list};
use crate::next_action::next_action;
use crate::scopes::DOMAINS_READ;

pub(super) fn command() -> RuntimeCommandSpec {
Expand Down Expand Up @@ -72,12 +73,12 @@ pub(super) fn command() -> RuntimeCommandSpec {
.collect();
Ok(
CommandResult::new(json!(agreements)).with_next_actions(vec![
NextAction::new(
next_action(
"domain quote <domain>",
"Price a registration and see the agreements for a specific domain",
)
.with_param("domain", NextActionParam::required()),
NextAction::new(
next_action(
"domain purchase --quote-token <quote-token> --agree --confirm",
"Register once you have a quote",
)
Expand Down
9 changes: 4 additions & 5 deletions rust/src/domain/available.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//! `gddy domain available` — check whether a domain can be registered (v3).

use cli_engine::{
CommandResult, CommandSpec, NextAction, NextActionParam, RuntimeCommandSpec, Tier,
};
use cli_engine::{CommandResult, CommandSpec, NextActionParam, RuntimeCommandSpec, Tier};
use serde_json::json;

use domains_client::types;

use super::common::{api_error, format_money, headline_price, make_client};
use crate::next_action::next_action;
use crate::output_schema::output_schema;
use crate::scopes::DOMAINS_READ;

Expand Down Expand Up @@ -107,12 +106,12 @@ pub(super) fn command() -> RuntimeCommandSpec {
let cmd = CommandResult::new(result);
if body.available.unwrap_or(false) {
Ok(cmd.with_next_actions(vec![
NextAction::new("domain quote <domain>", "Price a registration")
next_action("domain quote <domain>", "Price a registration")
.with_param("domain", NextActionParam::required()),
]))
} else {
Ok(cmd.with_next_actions(vec![
NextAction::new("domain suggest <query>", "Find alternatives")
next_action("domain suggest <query>", "Find alternatives")
.with_param("query", NextActionParam::required()),
]))
}
Expand Down
15 changes: 13 additions & 2 deletions rust/src/domain/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ pub(super) fn format_money(money: &types::SimpleMoney) -> Option<String> {
}

/// The headline price among per-term prices: the 1-year term if present, else the
/// first listed term. Shared by `available` and `suggest`, which both surface a
/// single indicative price from a `TermPrice` array.
/// first listed term. Used by `available`, which surfaces a single indicative
/// price from a `TermPrice` array.
pub(super) fn headline_price(prices: &[types::TermPrice]) -> Option<&types::TermPrice> {
let one_year = std::num::NonZeroU64::new(1);
prices
Expand All @@ -68,6 +68,17 @@ pub(super) fn headline_price(prices: &[types::TermPrice]) -> Option<&types::Term
.or_else(|| prices.first())
}

/// The entry for a specific year-term period (1, 2, …), or `None` when that term
/// isn't in the list. Used by `suggest` to flatten multiple terms into scalar
/// per-period fields (e.g. `price1Year`, `price2Year`).
Comment thread
jpage-godaddy marked this conversation as resolved.
pub(super) fn term_for_period(
prices: &[types::TermPrice],
period: u64,
) -> Option<&types::TermPrice> {
let period = std::num::NonZeroU64::new(period)?;
prices.iter().find(|p| p.period == Some(period))
}

/// Whether an async domain-operation status is terminal (no further polling).
/// Only `COMPLETED`/`FAILED` are terminal; every other status (e.g. `SUBMITTED`,
/// `PENDING`, `CONFIRMED`, `EXECUTING`) is treated as still in progress.
Expand Down
6 changes: 3 additions & 3 deletions rust/src/domain/contacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
//! `domain quote`/`purchase`. This is a local-file command group; no API/auth.

use cli_engine::{
CliCoreError, CommandResult, CommandSpec, GroupSpec, NextAction, RuntimeCommandSpec,
RuntimeGroupSpec, Tier,
CliCoreError, CommandResult, CommandSpec, GroupSpec, RuntimeCommandSpec, RuntimeGroupSpec, Tier,
};
use serde_json::json;

use crate::contacts;
use crate::next_action::next_action;

pub(super) fn group() -> RuntimeGroupSpec {
RuntimeGroupSpec::new(
Expand Down Expand Up @@ -64,7 +64,7 @@ pub(super) fn group() -> RuntimeGroupSpec {
"path": path.display().to_string(),
"action": if existed { "overwritten" } else { "created" },
}))
.with_next_actions(vec![NextAction::new(
.with_next_actions(vec![next_action(
"guide domain-purchase",
"Learn how purchase uses these contacts",
)]))
Expand Down
5 changes: 3 additions & 2 deletions rust/src/domain/get.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! `gddy domain get` — show full details for one owned domain (v3).

use cli_engine::{
CliCoreError, CommandResult, CommandSpec, NextAction, NextActionParam, RuntimeCommandSpec, Tier,
CliCoreError, CommandResult, CommandSpec, NextActionParam, RuntimeCommandSpec, Tier,
};

use domains_client::types;

use super::common::{api_error, make_client};
use crate::next_action::next_action;
use crate::scopes::DOMAINS_READ;

pub(super) fn command() -> RuntimeCommandSpec {
Expand Down Expand Up @@ -49,7 +50,7 @@ pub(super) fn command() -> RuntimeCommandSpec {
CliCoreError::message(format!("failed to serialize domain details: {e}"))
})?;
Ok(CommandResult::new(value).with_next_actions(vec![
NextAction::new("dns list <domain>", "View this domain's DNS records")
next_action("dns list <domain>", "View this domain's DNS records")
.with_param("domain", NextActionParam::required()),
]))
},
Expand Down
Loading