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
1 change: 1 addition & 0 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Write-Info "gddy installed successfully!"
Write-Host ""
Write-Host " Binary: $(Join-Path $Prefix $bin)"
Write-Host " Verify: gddy --version"
Write-Host " Tip: run 'gddy completion --install' for shell tab-completion"
Write-Host ""
Write-Host " Note: gddy installs alongside the legacy 'godaddy' CLI."
Write-Host ""
Expand Down
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ info "gddy (${VERSION:-latest}) installed successfully!"
echo ""
echo " Binary: ${PREFIX}/${BIN}"
echo " Verify: gddy --version"
echo " Tip: run 'gddy completion --install' for shell tab-completion"
echo ""
if ! printf '%s' ":$PATH:" | grep -qF ":${PREFIX}:"; then
warn "${PREFIX} is not on your PATH — add it to use 'gddy' directly."
Expand Down
35 changes: 33 additions & 2 deletions rust/src/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Duration;

use cli_engine::{
CliCoreError, CommandResult, CommandSpec, GroupSpec, Module, RuntimeCommandSpec,
CliCoreError, CommandResult, CommandSpec, GroupSpec, Module, NextAction, RuntimeCommandSpec,
RuntimeGroupSpec, Tier,
};
use serde::{Deserialize, Serialize};
use serde_json::json;
use sha2::{Digest, Sha256};

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

output_schema!(UpdateCheckResult {
Expand Down Expand Up @@ -141,10 +142,31 @@ fn apply_command() -> RuntimeCommandSpec {
.no_auth(true)
.with_output_schema::<UpdateApplyResult>()
.with_default_fields("previousVersion,newVersion,status"),
|_cred, args: ApplyArgs| async move { Ok(CommandResult::new(run_apply(args.force).await?)) },
|_cred, args: ApplyArgs| async move {
let result = run_apply(args.force).await?;
let next_actions =
completion_next_actions(result["status"].as_str().unwrap_or_default());
Ok(CommandResult::new(result).with_next_actions(next_actions))
},
)
}

/// Suggests refreshing shell completions after a real binary swap — the
/// command tree may have changed since completions were last generated.
/// Skipped when nothing actually changed (`"already up to date"`) so the
/// hint doesn't nag on every run of this frequently-scripted, no-auth
/// command.
fn completion_next_actions(status: &str) -> Vec<NextAction> {
if status == "updated" {
vec![next_action(
"completion --install",
"Refresh shell completions for the updated command set",
)]
} else {
Vec::new()
}
}

async fn run_apply(force: bool) -> Result<serde_json::Value, CliCoreError> {
let current = current_version();
let client = http_client()?;
Expand Down Expand Up @@ -523,6 +545,15 @@ mod tests {

use super::*;

#[test]
fn completion_next_actions_suggests_refresh_only_after_a_real_update() {
let actions = completion_next_actions("updated");
assert_eq!(actions.len(), 1);
assert_eq!(actions[0].command, "gddy completion --install");

assert!(completion_next_actions("already up to date").is_empty());
}

#[test]
fn parses_tags_with_and_without_v_prefix() {
assert_eq!(
Expand Down
Loading