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
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: cargo fmt --check

- name: Lint
run: cargo clippy -- -D warnings
run: cargo clippy --all-targets -- -D warnings

- name: Test
run: cargo test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust-port-alpha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
restore-keys: ${{ runner.os }}-cargo-test-

- name: Clippy
run: cargo clippy -- -D warnings
run: cargo clippy --all-targets -- -D warnings

- name: Test
run: cargo test
Expand Down
32 changes: 28 additions & 4 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = "src/main.rs"
async-trait = "0.1"
chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] }
clap = { version = "4.5", features = ["std", "string"] }
cli-engine = { features = ["pkce-auth"], version = "0.4.0" }
cli-engine = { features = ["pkce-auth"], version = "0.4.1" }
dirs = "6"
domains-client = { path = "domains-client" }
fancy-regex = "0.14"
Expand Down
8 changes: 6 additions & 2 deletions rust/src/actions_catalog/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use cli_engine::{
CommandResult, CommandSpec, GroupSpec, Module, RuntimeCommandSpec, RuntimeGroupSpec, Tier,
CommandResult, CommandSpec, GroupSpec, Module, NextAction, NextActionParam, RuntimeCommandSpec,
RuntimeGroupSpec, Tier,
};
use serde_json::json;

Expand Down Expand Up @@ -85,7 +86,10 @@ pub fn module() -> Module {
.iter()
.map(|(name, description)| json!({ "name": name, "description": description }))
.collect();
Ok(CommandResult::new(json!({ "actions": actions })))
Ok(CommandResult::new(json!({ "actions": actions })).with_next_actions(vec![
NextAction::new("actions describe <action>", "See an action's full schema")
.with_param("action", NextActionParam::required()),
]))
},
))
.with_command(RuntimeCommandSpec::new_with_context(
Expand Down
40 changes: 35 additions & 5 deletions rust/src/dns/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
//! `--dry-run` short-circuits them with a preview.

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

Expand Down Expand Up @@ -348,6 +348,18 @@ 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(
"dns list <domain> --type <type> --name <name>",
"Verify the records for this type+name",
)
.with_param("domain", NextActionParam::value(domain))
.with_param("type", NextActionParam::value(record_type))
.with_param("name", NextActionParam::value(name))
}

/// Summarize the per-record create outcomes of `dns add` (each `--data` value
/// paired with `Ok(())` or an `Err(message)`), preserving input order. Returns
/// the success JSON payload when *every* record was created, or an error message
Expand Down Expand Up @@ -665,7 +677,13 @@ pub fn module() -> Module {
// All-created → success payload; any failure → non-zero error
// with a per-record breakdown.
summarize_add_outcomes(&domain, &record_type, &name, outcomes)
.map(CommandResult::new)
.map(|v| {
CommandResult::new(v).with_next_actions(vec![verify_with_list_action(
&domain,
&record_type,
&name,
)])
})
.map_err(CliCoreError::message)
},
))
Expand Down Expand Up @@ -781,7 +799,13 @@ pub fn module() -> Module {
}

summarize_set_outcomes(&domain, &record_type, &name, &outcomes)
.map(CommandResult::new)
.map(|v| {
CommandResult::new(v).with_next_actions(vec![verify_with_list_action(
&domain,
&record_type,
&name,
)])
})
.map_err(CliCoreError::message)
},
))
Expand Down Expand Up @@ -870,7 +894,13 @@ pub fn module() -> Module {
}

summarize_delete_outcomes(&domain, &record_type, &name, &outcomes)
.map(CommandResult::new)
.map(|v| {
CommandResult::new(v).with_next_actions(vec![verify_with_list_action(
&domain,
&record_type,
&name,
)])
})
.map_err(CliCoreError::message)
},
))
Expand Down
19 changes: 17 additions & 2 deletions rust/src/domain/agreements.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! `gddy domain agreements` — the legal agreements a TLD requires (v1).

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

use domains_client::types;
Expand Down Expand Up @@ -68,7 +70,20 @@ pub(super) fn command() -> RuntimeCommandSpec {
})
})
.collect();
Ok(CommandResult::new(json!(agreements)))
Ok(
CommandResult::new(json!(agreements)).with_next_actions(vec![
NextAction::new(
"domain quote <domain>",
"Price a registration and see the agreements for a specific domain",
)
.with_param("domain", NextActionParam::required()),
NextAction::new(
"domain purchase --quote-token <quote-token> --agree --confirm",
"Register once you have a quote",
)
.with_param("quote-token", NextActionParam::required()),
]),
)
},
)
}
8 changes: 6 additions & 2 deletions rust/src/domain/nameservers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! `gddy domain nameservers` — manage a domain's nameservers (v3).

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

Expand Down Expand Up @@ -91,7 +92,10 @@ pub(super) fn group() -> RuntimeGroupSpec {
if let Some(status) = op.status.as_ref() {
result["status"] = json!(status.to_string());
}
Ok(CommandResult::new(result))
Ok(CommandResult::new(result).with_next_actions(vec![
NextAction::new("domain get <domain>", "Confirm the updated nameservers")
.with_param("domain", NextActionParam::value(domain)),
Comment thread
jpage-godaddy marked this conversation as resolved.
Resolved
]))
},
))
}
4 changes: 2 additions & 2 deletions rust/src/domain/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ pub(super) fn command() -> RuntimeCommandSpec {
}
next_actions.push(
NextAction::new(
"domain purchase --quote-token <token> --agree --confirm",
"domain purchase --quote-token <quote-token> --agree --confirm",
"Register at the quoted price (within ~10 minutes)",
)
.with_param("quote-token", NextActionParam::required()),
.with_param("quote-token", NextActionParam::value(token)),
);
} else {
// Not available (or no token was issued): point at discovery, the
Expand Down
13 changes: 12 additions & 1 deletion rust/src/hosting/nodejs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,18 @@ fn status_command() -> RuntimeCommandSpec {
let app_id = required_str(&ctx, "app-id", "--app-id")?;
let client = make_client(&ctx, &[APPS_READ]).await?;
let data = client.get_app_status(&app_id).await.map_err(client_err)?;
Ok(CommandResult::new(data))
Ok(CommandResult::new(data).with_next_actions(vec![
NextAction::new(
"hosting nodejs deployment list --app-id <app-id>",
"List deployments for this application",
)
.with_param("app-id", NextActionParam::value(app_id.clone())),
NextAction::new(
"hosting nodejs logs --app-id <app-id>",
"View application logs",
)
.with_param("app-id", NextActionParam::value(app_id)),
]))
},
)
}
Expand Down
12 changes: 6 additions & 6 deletions rust/src/pat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ mod tests {
"token".to_owned(),
serde_json::Value::String(" gd_pat_a_12345678 \n".to_owned()),
);
let token = resolve_token_arg(&args).await.unwrap();
let token = resolve_token_arg(&args).await.expect("token arg resolves");
assert_eq!(token, "gd_pat_a_12345678");
assert!(is_valid_pat(&token));
}
Expand All @@ -536,7 +536,7 @@ mod tests {
assert!(parse_stdin_token("", 0).is_err());
assert!(parse_stdin_token(" \n", 3).is_err());
assert_eq!(
parse_stdin_token(" gd_pat_a_12345678 \n", 23).unwrap(),
parse_stdin_token(" gd_pat_a_12345678 \n", 23).expect("token parses"),
"gd_pat_a_12345678"
);
}
Expand Down Expand Up @@ -582,7 +582,7 @@ mod tests {
"GDDY_PAT" => Some("gd_pat_default_12345678".to_owned()),
_ => None,
};
let entry = resolve_pat_with("prod", env, Some(&registry)).unwrap();
let entry = resolve_pat_with("prod", env, Some(&registry)).expect("pat resolves");
assert_eq!(entry.token, "gd_pat_prod_12345678");
assert_eq!(entry.name, "env");
}
Expand All @@ -594,7 +594,7 @@ mod tests {
"GDDY_PAT" => Some("gd_pat_default_12345678".to_owned()),
_ => None,
};
let entry = resolve_pat_with("prod", env, Some(&registry)).unwrap();
let entry = resolve_pat_with("prod", env, Some(&registry)).expect("pat resolves");
assert_eq!(entry.token, "gd_pat_default_12345678");
assert_eq!(entry.name, "env");
}
Expand All @@ -607,15 +607,15 @@ mod tests {
"GDDY_PAT" => Some("gd_pat_default_12345678".to_owned()),
_ => None,
};
let entry = resolve_pat_with("prod", env, Some(&registry)).unwrap();
let entry = resolve_pat_with("prod", env, Some(&registry)).expect("pat resolves");
assert_eq!(entry.token, "gd_pat_default_12345678");
}

#[test]
fn registry_entry_returned_when_no_env_vars() {
let registry = test_registry_with("prod", "gd_pat_registry_12345678");
let env = |_var: &str| None;
let entry = resolve_pat_with("prod", env, Some(&registry)).unwrap();
let entry = resolve_pat_with("prod", env, Some(&registry)).expect("pat resolves");
assert_eq!(entry.token, "gd_pat_registry_12345678");
assert_eq!(entry.name, "stored");
}
Expand Down
13 changes: 10 additions & 3 deletions rust/src/payments/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! `gddy payments` — payment method management.

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

Expand Down Expand Up @@ -52,7 +52,14 @@ fn add_command() -> RuntimeCommandSpec {
"Could not open browser. Visit the URL above to add a payment method. \
Only credit card or Good-as-Gold can be used for domain purchases."
}
})))
}))
.with_next_actions(vec![
NextAction::new(
"domain quote <domain>",
"Price a domain registration now that a payment method is on file",
)
.with_param("domain", NextActionParam::required()),
]))
},
)
}
Expand Down