Skip to content

Commit 3d26447

Browse files
committed
Remove unsupported onboard key prompts
1 parent c92fd01 commit 3d26447

4 files changed

Lines changed: 11 additions & 78 deletions

File tree

garyx/src/cli.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ pub(crate) enum Commands {
7777
/// API account id to create or enable for gateway/API usage
7878
#[arg(long, default_value = "main")]
7979
api_account: String,
80-
/// Search API key to persist in gateway.search.api_key
81-
#[arg(long)]
82-
search_api_key: Option<String>,
8380
/// Start the gateway after onboarding completes
8481
#[arg(long)]
8582
run_gateway: bool,

garyx/src/commands.rs

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ pub(crate) struct OnboardCommandOptions {
7878
pub force: bool,
7979
pub json: bool,
8080
pub api_account: String,
81-
pub search_api_key: Option<String>,
8281
pub run_gateway: bool,
8382
pub port_override: Option<u16>,
8483
pub host_override: Option<String>,
@@ -7395,21 +7394,13 @@ pub(crate) async fn cmd_doctor(
73957394
Ok(())
73967395
}
73977396

7398-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7399-
enum SecretPromptUpdate {
7400-
Keep,
7401-
Clear,
7402-
Set,
7403-
}
7404-
74057397
#[derive(Debug, Serialize)]
74067398
struct OnboardSummary {
74077399
ok: bool,
74087400
config_path: String,
74097401
created_config: bool,
74107402
api_account: String,
74117403
api_account_created: bool,
7412-
search_api_key_configured: bool,
74137404
gateway_run_requested: bool,
74147405
/// `channel.account` identifiers bound during this onboarding session.
74157406
channels_bound: Vec<String>,
@@ -7437,14 +7428,6 @@ fn prompt_line(prompt: &str) -> Result<String, Box<dyn std::error::Error>> {
74377428
Ok(buf.trim().to_owned())
74387429
}
74397430

7440-
fn prompt_secret_line(prompt: &str) -> Result<String, Box<dyn std::error::Error>> {
7441-
if stdin_is_interactive() {
7442-
Ok(rpassword::prompt_password(prompt)?.trim().to_owned())
7443-
} else {
7444-
prompt_line(prompt)
7445-
}
7446-
}
7447-
74487431
fn prompt_yes_no(prompt: &str, default: bool) -> Result<bool, Box<dyn std::error::Error>> {
74497432
let suffix = if default { "[Y/n]" } else { "[y/N]" };
74507433
loop {
@@ -7463,25 +7446,6 @@ fn prompt_yes_no(prompt: &str, default: bool) -> Result<bool, Box<dyn std::error
74637446
}
74647447
}
74657448

7466-
fn prompt_secret_update(
7467-
label: &str,
7468-
configured: bool,
7469-
) -> Result<(SecretPromptUpdate, Option<String>), Box<dyn std::error::Error>> {
7470-
let prompt = if configured {
7471-
format!("{label} (Enter keeps current, '-' clears): ")
7472-
} else {
7473-
format!("{label} (optional, Enter skips): ")
7474-
};
7475-
let value = prompt_secret_line(&prompt)?;
7476-
if value.is_empty() {
7477-
return Ok((SecretPromptUpdate::Keep, None));
7478-
}
7479-
if value == "-" {
7480-
return Ok((SecretPromptUpdate::Clear, None));
7481-
}
7482-
Ok((SecretPromptUpdate::Set, Some(value)))
7483-
}
7484-
74857449
fn ensure_onboard_api_account(config: &mut GaryxConfig, account_id: &str) -> bool {
74867450
let account_id = account_id.trim();
74877451
if let Some(account) = config.channels.api.accounts.get_mut(account_id) {
@@ -7531,14 +7495,6 @@ fn print_onboard_summary(summary: &OnboardSummary) {
75317495
} else {
75327496
println!("API account: {} (enabled)", summary.api_account);
75337497
}
7534-
println!(
7535-
"Search API key: {}",
7536-
if summary.search_api_key_configured {
7537-
"configured"
7538-
} else {
7539-
"missing"
7540-
}
7541-
);
75427498
if summary.channels_bound.is_empty() {
75437499
println!(
75447500
"User-facing channels: {} configured (none bound this session)",
@@ -7578,10 +7534,6 @@ pub(crate) async fn cmd_onboard(
75787534
trim_to_option(Some(options.api_account.as_str())).unwrap_or_else(|| "main".to_owned());
75797535
let api_account_created = ensure_onboard_api_account(&mut cfg, &api_account);
75807536

7581-
if let Some(value) = trim_to_option(options.search_api_key.as_deref()) {
7582-
cfg.gateway.search.api_key = value;
7583-
}
7584-
75857537
let interactive = !options.json && stdin_is_interactive();
75867538
let mut channels_bound: Vec<String> = Vec::new();
75877539
if interactive {
@@ -7593,22 +7545,6 @@ pub(crate) async fn cmd_onboard(
75937545
}
75947546
println!("Gateway/API account `{api_account}` will be available after setup.");
75957547

7596-
if options.search_api_key.is_none() {
7597-
let (action, value) = prompt_secret_update(
7598-
"Search API key",
7599-
!cfg.gateway.search.api_key.trim().is_empty(),
7600-
)?;
7601-
match action {
7602-
SecretPromptUpdate::Keep => {}
7603-
SecretPromptUpdate::Clear => cfg.gateway.search.api_key.clear(),
7604-
SecretPromptUpdate::Set => {
7605-
if let Some(value) = value {
7606-
cfg.gateway.search.api_key = value;
7607-
}
7608-
}
7609-
}
7610-
}
7611-
76127548
// ---- Channel binding ----
76137549
// The api.* account auto-created above lets programs talk to gateway,
76147550
// but a human needs at least one user-facing channel (telegram /
@@ -7659,7 +7595,6 @@ pub(crate) async fn cmd_onboard(
76597595
created_config,
76607596
api_account: api_account.clone(),
76617597
api_account_created,
7662-
search_api_key_configured: !cfg.gateway.search.api_key.trim().is_empty(),
76637598
gateway_run_requested: options.run_gateway,
76647599
channels_bound,
76657600
total_user_channel_accounts: user_channel_account_count(&cfg),

garyx/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
421421
Some(Commands::Onboard {
422422
force,
423423
api_account,
424-
search_api_key,
425424
run_gateway: onboard_run_gateway,
426425
json,
427426
}) => {
@@ -431,7 +430,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
431430
force,
432431
json,
433432
api_account,
434-
search_api_key,
435433
run_gateway: onboard_run_gateway,
436434
port_override: cli.port,
437435
host_override: cli.host,

garyx/src/main_tests.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,25 +520,30 @@ fn parse_onboard_flags() {
520520
"onboard",
521521
"--api-account",
522522
"gateway",
523-
"--search-api-key",
524-
"search-key",
525523
"--run-gateway",
526524
]);
527525
match cli.command {
528526
Some(Commands::Onboard {
529527
api_account,
530-
search_api_key,
531528
run_gateway,
532529
..
533530
}) => {
534531
assert_eq!(api_account, "gateway");
535-
assert_eq!(search_api_key.as_deref(), Some("search-key"));
536532
assert!(run_gateway);
537533
}
538534
_ => panic!("expected Onboard"),
539535
}
540536
}
541537

538+
#[test]
539+
fn parse_onboard_rejects_search_api_key_flag() {
540+
let result = Cli::try_parse_from(["garyx", "onboard", "--search-api-key", "search-key"]);
541+
assert!(
542+
result.is_err(),
543+
"onboard should not accept unsupported search API key setup"
544+
);
545+
}
546+
542547
#[test]
543548
fn parse_config_set() {
544549
let cli = Cli::parse_from(["garyx", "config", "set", "gateway.port", "8080"]);
@@ -1867,7 +1872,7 @@ fn load_config_or_default_missing_file() {
18671872
}
18681873

18691874
#[tokio::test]
1870-
async fn onboard_writes_gateway_keys_and_api_account() {
1875+
async fn onboard_writes_api_account_without_search_key_setup() {
18711876
let tmp = tempfile::TempDir::new().unwrap();
18721877
let config_path = tmp.path().join("gary.json");
18731878

@@ -1877,7 +1882,6 @@ async fn onboard_writes_gateway_keys_and_api_account() {
18771882
force: false,
18781883
json: true,
18791884
api_account: "main".to_owned(),
1880-
search_api_key: Some("search-key".to_owned()),
18811885
run_gateway: false,
18821886
port_override: None,
18831887
host_override: None,
@@ -1895,7 +1899,7 @@ async fn onboard_writes_gateway_keys_and_api_account() {
18951899
let config = loaded.config;
18961900
let api_account = config.channels.api.accounts.get("main").unwrap();
18971901
assert!(api_account.enabled);
1898-
assert_eq!(config.gateway.search.api_key, "search-key");
1902+
assert!(config.gateway.search.api_key.is_empty());
18991903
}
19001904

19011905
#[tokio::test]
@@ -1924,7 +1928,6 @@ async fn onboard_updates_existing_config_without_resetting_other_fields() {
19241928
force: false,
19251929
json: true,
19261930
api_account: "custom".to_owned(),
1927-
search_api_key: None,
19281931
run_gateway: false,
19291932
port_override: None,
19301933
host_override: None,

0 commit comments

Comments
 (0)