use things3_cli::{Cli, Commands};
#[test]
fn test_core_cli_features_always_available() {
use clap::Parser;
let args = vec!["things3", "inbox"];
let result = Cli::try_parse_from(args);
assert!(result.is_ok());
}
#[cfg(feature = "mcp-server")]
#[test]
fn test_mcp_server_feature_enabled() {
use clap::Parser;
let args = vec!["things3", "mcp"];
let cli = Cli::try_parse_from(args);
assert!(
cli.is_ok(),
"MCP command should be available when feature is enabled"
);
if let Ok(cli) = cli {
assert!(
matches!(cli.command, Commands::Mcp),
"Should parse as Mcp command"
);
}
}
#[cfg(not(feature = "mcp-server"))]
#[test]
fn test_mcp_server_feature_disabled() {
use clap::Parser;
let args = vec!["things3", "mcp"];
let result = Cli::try_parse_from(args);
assert!(
result.is_err(),
"MCP command should not be available when feature is disabled"
);
}
#[cfg(feature = "export-csv")]
#[test]
fn test_csv_export_cli_feature_enabled() {
use clap::Parser;
let args = vec!["things3", "bulk", "export", "--format", "csv"];
let cli = Cli::try_parse_from(args);
assert!(
cli.is_ok(),
"Bulk export CSV command should be available when feature is enabled"
);
}
#[cfg(feature = "export-opml")]
#[test]
fn test_opml_export_cli_feature_enabled() {
use clap::Parser;
let args = vec!["things3", "bulk", "export", "--format", "json"];
let cli = Cli::try_parse_from(args);
assert!(cli.is_ok(), "Bulk export command should be available");
}
#[cfg(feature = "observability")]
#[test]
fn test_observability_cli_commands_available() {
use clap::Parser;
let args = vec!["things3", "health-server", "--port", "8080"];
let cli = Cli::try_parse_from(args);
assert!(
cli.is_ok(),
"Health server command should be available with observability feature"
);
if let Ok(cli) = cli {
assert!(
matches!(cli.command, Commands::HealthServer { .. }),
"Should parse as HealthServer command"
);
}
let args = vec!["things3", "dashboard", "--port", "3030"];
let cli = Cli::try_parse_from(args);
assert!(
cli.is_ok(),
"Dashboard command should be available with observability feature"
);
if let Ok(cli) = cli {
assert!(
matches!(cli.command, Commands::Dashboard { .. }),
"Should parse as Dashboard command"
);
}
}
#[cfg(not(feature = "observability"))]
#[test]
fn test_observability_cli_commands_unavailable() {
use clap::Parser;
let args = vec!["things3", "health-server"];
let cli = Cli::try_parse_from(args);
assert!(
cli.is_err(),
"Health server command should not be available without observability feature"
);
let args = vec!["things3", "dashboard"];
let cli = Cli::try_parse_from(args);
assert!(
cli.is_err(),
"Dashboard command should not be available without observability feature"
);
}
#[cfg(all(feature = "mcp-server", feature = "observability"))]
#[test]
fn test_multiple_cli_features_enabled() {
use clap::Parser;
let mcp_args = vec!["things3", "mcp"];
let mcp_cli = Cli::try_parse_from(mcp_args);
assert!(mcp_cli.is_ok(), "MCP command should be available");
let health_args = vec!["things3", "health-server"];
let health_cli = Cli::try_parse_from(health_args);
assert!(
health_cli.is_ok(),
"Health server command should be parseable"
);
let dashboard_args = vec!["things3", "dashboard"];
let dashboard_cli = Cli::try_parse_from(dashboard_args);
assert!(
dashboard_cli.is_ok(),
"Dashboard command should be parseable"
);
}
#[cfg(all(
feature = "mcp-server",
feature = "export-csv",
feature = "export-opml",
feature = "observability"
))]
#[test]
fn test_all_cli_features_enabled() {
use clap::Parser;
let test_cases = vec![
(vec!["things3", "mcp"], "MCP"),
(
vec!["things3", "bulk", "export", "--format", "csv"],
"CSV export",
),
(
vec!["things3", "bulk", "export", "--format", "json"],
"JSON export",
),
(vec!["things3", "health-server"], "Health server"),
(vec!["things3", "dashboard"], "Dashboard"),
];
for (args, description) in test_cases {
let cli = Cli::try_parse_from(args);
assert!(
cli.is_ok(),
"{} command should be available with all features",
description
);
}
}
#[test]
fn test_core_commands_always_available() {
use clap::Parser;
let core_commands = vec![
vec!["things3", "inbox"],
vec!["things3", "today"],
vec!["things3", "projects"],
vec!["things3", "areas"],
vec!["things3", "search", "test"],
vec!["things3", "health"],
vec!["things3", "server"],
vec!["things3", "watch"],
vec!["things3", "validate"],
vec!["things3", "bulk", "export"],
];
for args in core_commands {
let cli = Cli::try_parse_from(args.clone());
assert!(
cli.is_ok(),
"Core command {:?} should always be available",
args[1]
);
}
}
#[test]
fn test_default_features() {
use clap::Parser;
let args = vec!["things3", "inbox"];
let cli = Cli::try_parse_from(args);
assert!(
cli.is_ok(),
"Core commands should work with default features"
);
#[cfg(all(
feature = "mcp-server",
feature = "export-csv",
feature = "export-opml",
feature = "observability"
))]
{
let mcp_args = vec!["things3", "mcp"];
let mcp_cli = Cli::try_parse_from(mcp_args);
assert!(
mcp_cli.is_ok(),
"MCP command should work with default features"
);
}
#[cfg(not(all(
feature = "mcp-server",
feature = "export-csv",
feature = "export-opml",
feature = "observability"
)))]
{
}
}
#[test]
fn test_feature_combinations() {
use clap::Parser;
let args = vec!["things3", "--help"];
let result = Cli::try_parse_from(args);
assert!(
result.is_ok() || result.is_err(),
"CLI should handle help command gracefully"
);
}