Skip to content

Commit ae043d7

Browse files
feat: improve CLI help text accuracy and add comprehensive test coverage (#444)
* fix(redis-enterprise): remove non-existent database action methods Remove three database action methods that call non-existent API endpoints: - BdbHandler::start() - /v1/bdbs/{uid}/actions/start (404) - BdbHandler::stop() - /v1/bdbs/{uid}/actions/stop (404) - BdbHandler::restart() - /v1/bdbs/{uid}/actions/restart (404) Testing against Docker cluster and comprehensive documentation search of redis.io REST API docs confirms these endpoints do not exist. The complete list of documented database action endpoints is: - stop_traffic / resume_traffic (NOT the same as stop/start) - export / import / recover - optimize_shards_placement / rebalance - backup_reset_status / import_reset_status / export_reset_status Also removed associated tests and updated documentation to use correct endpoints (stop_traffic/resume_traffic instead of restart). Closes #421 * feat(cli): improve profile command clarity with --type flag BREAKING CHANGE: Changed --deployment flag to --type for profile set command - Renamed --deployment to --type for better clarity (cloud vs enterprise) - Added --deployment as a visible alias for backward compatibility - Updated all help text examples to use --type consistently - Changed help text from 'Deployment type' to 'Platform type: cloud or enterprise' - Fixed incorrect examples that showed positional argument syntax The --type flag more clearly indicates this is selecting between Redis Cloud and Redis Enterprise platforms, reducing confusion with deployment environments. The --deployment alias maintains backward compatibility for existing scripts. * fix(cli): standardize slow-log command help text and add comprehensive tests - Fixed slow-log description inconsistency ('View' vs 'Get slow query log') - Added default values (100, 0) for limit/offset in fixed-database slow-log - Standardized offset description to 'Offset for pagination' - Changed limit/offset from Option<i32> to i32 with defaults for consistency Added comprehensive assert_cmd tests to ensure documentation accuracy: - 14 new tests for profile --type flag and backward compatibility - 8 new tests for slow-log command consistency - Updated existing test to check for --type instead of --deployment - All tests verify help text matches actual command behavior These tests will catch documentation drift and ensure users can rely on our help text and examples. * test(cli): add comprehensive help text coverage for all major commands Added 36 new help text tests to ensure documentation accuracy: Files-key commands (4 tests): - Verify all subcommands have accurate help text - Covers set, get, remove operations API command (2 tests): - Verify examples show correct syntax - Verify completions command help Cloud subcommands (13 tests): - account, subscription, database, user, acl operations - task, connectivity, fixed-database, fixed-subscription - workflow operations - All verify help text matches actual command behavior Enterprise subcommands (17 tests): - cluster, database, node, user, role, acl operations - license, support-package, workflow, crdb operations - proxy, module management - Covers most common user-facing commands Total test count increased from 34 to 70 tests in cli_basic_tests.rs. This ensures users can rely on --help output being accurate and prevents documentation drift as commands evolve. * chore: trigger CI re-run * fix(clippy): use derive for Default impl on OutputFormat Rust 1.91 introduced a new lint 'derivable_impls' that flags manual Default implementations that can be derived. Changed OutputFormat to use #[derive(Default)] with #[default] attribute on the Json variant. Fixes CI clippy failure on Rust 1.91.0.
1 parent f48c252 commit ae043d7

File tree

5 files changed

+815
-32
lines changed

5 files changed

+815
-32
lines changed

crates/redisctl/src/cli.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Redis management CLI for Cloud and Enterprise deployments
2020
2121
EXAMPLES:
2222
# Set up a Cloud profile
23-
redisctl profile set mycloud cloud --api-key KEY --api-secret SECRET
23+
redisctl profile set mycloud --type cloud --api-key KEY --api-secret SECRET
2424
2525
# Set up an Enterprise profile
26-
redisctl profile set myenterprise enterprise --url https://cluster:9443 --username admin
26+
redisctl profile set myenterprise --type enterprise --url https://cluster:9443 --username admin
2727
2828
# List databases
2929
redisctl cloud database list
@@ -102,7 +102,7 @@ pub enum Commands {
102102
redisctl api enterprise get /v1/bdbs -o json
103103
")]
104104
Api {
105-
/// Deployment type to target
105+
/// Platform type (cloud or enterprise)
106106
#[arg(value_enum)]
107107
deployment: DeploymentType,
108108

@@ -122,10 +122,10 @@ pub enum Commands {
122122
#[command(subcommand, visible_alias = "prof", visible_alias = "pr")]
123123
#[command(after_help = "EXAMPLES:
124124
# Create a Cloud profile
125-
redisctl profile set mycloud cloud --api-key KEY --api-secret SECRET
125+
redisctl profile set mycloud --type cloud --api-key KEY --api-secret SECRET
126126
127127
# Create an Enterprise profile
128-
redisctl profile set myenterprise enterprise --url https://cluster:9443 --username admin
128+
redisctl profile set myenterprise --type enterprise --url https://cluster:9443 --username admin
129129
130130
# List all profiles
131131
redisctl profile list
@@ -242,23 +242,23 @@ pub enum ProfileCommands {
242242
#[command(visible_alias = "add", visible_alias = "create")]
243243
#[command(after_help = "EXAMPLES:
244244
# Create a Cloud profile
245-
redisctl profile set mycloud cloud \\
245+
redisctl profile set mycloud --type cloud \\
246246
--api-key A3qcymrvqpn9rrgdt40sv5f9yfxob26vx64hwddh8vminqnkgfq \\
247247
--api-secret S3s8ecrrnaguqkvwfvealoe3sn25zqs4wc4lwgo4rb0ud3qm77c
248248
249249
# Create an Enterprise profile (password will be prompted)
250-
redisctl profile set prod enterprise \\
250+
redisctl profile set prod --type enterprise \\
251251
--url https://cluster.example.com:9443 \\
252252
--username [email protected]
253253
254254
# Create Enterprise profile with password
255-
redisctl profile set staging enterprise \\
255+
redisctl profile set staging --type enterprise \\
256256
--url https://staging:9443 \\
257257
--username admin \\
258258
--password mypassword
259259
260260
# Create Enterprise profile allowing insecure connections
261-
redisctl profile set local enterprise \\
261+
redisctl profile set local --type enterprise \\
262262
--url https://localhost:9443 \\
263263
--username [email protected] \\
264264
--insecure
@@ -267,28 +267,28 @@ pub enum ProfileCommands {
267267
/// Profile name
268268
name: String,
269269

270-
/// Deployment type
271-
#[arg(long, value_enum)]
272-
deployment: DeploymentType,
270+
/// Platform type: 'cloud' for Redis Cloud or 'enterprise' for Redis Enterprise
271+
#[arg(long, value_enum, visible_alias = "deployment")]
272+
r#type: DeploymentType,
273273

274274
/// API key (for Cloud profiles)
275-
#[arg(long, required_if_eq("deployment", "cloud"))]
275+
#[arg(long, required_if_eq("type", "cloud"))]
276276
api_key: Option<String>,
277277

278278
/// API secret (for Cloud profiles)
279-
#[arg(long, required_if_eq("deployment", "cloud"))]
279+
#[arg(long, required_if_eq("type", "cloud"))]
280280
api_secret: Option<String>,
281281

282282
/// API URL (for Cloud profiles)
283283
#[arg(long, default_value = "https://api.redislabs.com/v1")]
284284
api_url: String,
285285

286286
/// Enterprise URL (for Enterprise profiles)
287-
#[arg(long, required_if_eq("deployment", "enterprise"))]
287+
#[arg(long, required_if_eq("type", "enterprise"))]
288288
url: Option<String>,
289289

290290
/// Username (for Enterprise profiles)
291-
#[arg(long, required_if_eq("deployment", "enterprise"))]
291+
#[arg(long, required_if_eq("type", "enterprise"))]
292292
username: Option<String>,
293293

294294
/// Password (for Enterprise profiles)
@@ -984,17 +984,17 @@ pub enum CloudFixedDatabaseCommands {
984984
#[command(flatten)]
985985
async_ops: crate::commands::cloud::async_utils::AsyncOperationArgs,
986986
},
987-
/// View slow query log
987+
/// Get slow query log
988988
#[command(name = "slow-log")]
989989
SlowLog {
990990
/// Database ID (format: subscription_id:database_id)
991991
id: String,
992992
/// Maximum number of entries to return
993-
#[arg(long)]
994-
limit: Option<i32>,
995-
/// Number of entries to skip
996-
#[arg(long)]
997-
offset: Option<i32>,
993+
#[arg(long, default_value = "100")]
994+
limit: i32,
995+
/// Offset for pagination
996+
#[arg(long, default_value = "0")]
997+
offset: i32,
998998
},
999999
/// List tags for fixed database
10001000
#[command(name = "list-tags")]

crates/redisctl/src/commands/profile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub async fn handle_profile_command(
2424
Show { name } => handle_show(conn_mgr, name, output_format).await,
2525
Set {
2626
name,
27-
deployment,
27+
r#type,
2828
api_key,
2929
api_secret,
3030
api_url,
@@ -38,7 +38,7 @@ pub async fn handle_profile_command(
3838
handle_set(
3939
conn_mgr,
4040
name,
41-
deployment,
41+
r#type,
4242
api_key,
4343
api_secret,
4444
api_url,

crates/redisctl/src/output.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ use jmespath::compile;
66
use serde::Serialize;
77
use serde_json::Value;
88

9-
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
9+
#[derive(Debug, Clone, Copy, clap::ValueEnum, Default)]
1010
pub enum OutputFormat {
11+
#[default]
1112
Json,
1213
Yaml,
1314
Table,
1415
}
1516

16-
impl Default for OutputFormat {
17-
fn default() -> Self {
18-
Self::Json
19-
}
20-
}
21-
2217
impl OutputFormat {
2318
pub fn is_json(&self) -> bool {
2419
matches!(self, Self::Json)

0 commit comments

Comments
 (0)