1pub const FAILED_TO_SAVE: &str = "Failed to save";
11pub fn failed_to_save(e: &impl std::fmt::Display) -> String {
12 format!("{}: {}", FAILED_TO_SAVE, e)
13}
14
15pub const CONFIG_CHANGED_EXTERNALLY: &str =
16 "Config changed externally. Press Esc and re-open to pick up changes.";
17
18pub const DEMO_CONNECTION_DISABLED: &str = "Demo mode. Connection disabled.";
21pub const DEMO_SYNC_DISABLED: &str = "Demo mode. Sync disabled.";
22pub const DEMO_TUNNELS_DISABLED: &str = "Demo mode. Tunnels disabled.";
23pub const DEMO_VAULT_SIGNING_DISABLED: &str = "Demo mode. Vault SSH signing disabled.";
24pub const DEMO_FILE_BROWSER_DISABLED: &str = "Demo mode. File browser disabled.";
25pub const DEMO_CONTAINER_REFRESH_DISABLED: &str = "Demo mode. Container refresh disabled.";
26pub const DEMO_CONTAINER_ACTIONS_DISABLED: &str = "Demo mode. Container actions disabled.";
27pub const DEMO_EXECUTION_DISABLED: &str = "Demo mode. Execution disabled.";
28pub const DEMO_PROVIDER_CHANGES_DISABLED: &str = "Demo mode. Provider config changes disabled.";
29
30pub fn stale_host(hint: &str) -> String {
37 let trimmed = hint.trim().trim_end_matches('.');
38 if trimmed.is_empty() {
39 "Stale host.".to_string()
40 } else {
41 format!("Stale host. {}.", trimmed)
42 }
43}
44
45pub fn copied_ssh_command(alias: &str) -> String {
48 format!("Copied SSH command for {}.", alias)
49}
50
51pub fn copied_config_block(alias: &str) -> String {
52 format!("Copied config block for {}.", alias)
53}
54
55pub fn showing_unreachable(count: usize) -> String {
56 format!(
57 "Showing {} unreachable host{}.",
58 count,
59 if count == 1 { "" } else { "s" }
60 )
61}
62
63pub fn sorted_by(label: &str) -> String {
64 format!("Sorted by {}.", label)
65}
66
67pub fn sorted_by_save_failed(label: &str, e: &impl std::fmt::Display) -> String {
68 format!("Sorted by {}. (save failed: {})", label, e)
69}
70
71pub fn grouped_by(label: &str) -> String {
72 format!("Grouped by {}.", label)
73}
74
75pub fn grouped_by_save_failed(label: &str, e: &impl std::fmt::Display) -> String {
76 format!("Grouped by {}. (save failed: {})", label, e)
77}
78
79pub const UNGROUPED: &str = "Ungrouped.";
80
81pub fn ungrouped_save_failed(e: &impl std::fmt::Display) -> String {
82 format!("Ungrouped. (save failed: {})", e)
83}
84
85pub const GROUPED_BY_TAG: &str = "Grouped by tag.";
86
87pub fn grouped_by_tag_save_failed(e: &impl std::fmt::Display) -> String {
88 format!("Grouped by tag. (save failed: {})", e)
89}
90
91pub fn host_restored(alias: &str) -> String {
92 format!("{} is back from the dead.", alias)
93}
94
95pub fn restored_tags(count: usize) -> String {
96 format!(
97 "Restored tags on {} host{}.",
98 count,
99 if count == 1 { "" } else { "s" }
100 )
101}
102
103pub const NOTHING_TO_UNDO: &str = "Nothing to undo.";
104pub const NO_IMPORTABLE_HOSTS: &str = "No importable hosts in known_hosts.";
105pub const NO_STALE_HOSTS: &str = "No stale hosts.";
106pub const NO_HOST_SELECTED: &str = "No host selected.";
107pub const NO_HOSTS_TO_RUN: &str = "No hosts to run on.";
108pub const NO_HOSTS_TO_TAG: &str = "No hosts to tag.";
109pub const PING_FIRST: &str = "Ping first (p/P), then filter with !.";
110pub const PINGING_ALL: &str = "Pinging all the things...";
111pub const ESC_QUIT_HINT: &str = "Nothing to cancel. Press q to quit.";
112
113pub fn included_file_edit(name: &str) -> String {
114 format!("{} is in an included file. Edit it there.", name)
115}
116
117pub fn included_file_delete(name: &str) -> String {
118 format!("{} is in an included file. Delete it there.", name)
119}
120
121pub fn included_file_clone(name: &str) -> String {
122 format!("{} is in an included file. Clone it there.", name)
123}
124
125pub fn included_host_lives_in(alias: &str, path: &impl std::fmt::Display) -> String {
126 format!("{} lives in {}. Edit it there.", alias, path)
127}
128
129pub fn included_host_clone_there(alias: &str, path: &impl std::fmt::Display) -> String {
130 format!("{} lives in {}. Clone it there.", alias, path)
131}
132
133pub fn included_host_tag_there(alias: &str, path: &impl std::fmt::Display) -> String {
134 format!("{} is included from {}. Tag it there.", alias, path)
135}
136
137pub const HOST_NOT_FOUND_IN_CONFIG: &str = "Host not found in config.";
138
139pub const SMART_PARSED: &str = "Smart-parsed that for you. Check the fields.";
142pub const LOOKS_LIKE_ADDRESS: &str = "Looks like an address. Suggested as Host.";
143
144pub const HOST_ALIAS_EMPTY: &str = "Alias can't be empty. Every host needs a name!";
152pub const HOST_PATTERN_EMPTY: &str = "Pattern can't be empty.";
153pub const HOST_PATTERN_NEEDS_WILDCARD: &str =
154 "Pattern needs a wildcard (*, ?, [) or multiple hosts.";
155pub const HOST_ALIAS_WHITESPACE: &str = "Alias can't contain whitespace. Keep it simple.";
156pub const HOST_ALIAS_HASH: &str =
157 "Alias can't contain '#'. That's a comment character in SSH config.";
158pub const HOST_ALIAS_PATTERN_CHARS: &str =
159 "Alias can't contain pattern characters. That creates a match pattern, not a host.";
160pub const HOST_HOSTNAME_EMPTY: &str = "Hostname can't be empty. Where should we connect to?";
161pub const HOST_HOSTNAME_WHITESPACE: &str = "Hostname can't contain whitespace.";
162pub const HOST_PORT_INVALID: &str = "That's not a port number. Ports are 1-65535, not poetry.";
163pub const HOST_PORT_ZERO: &str = "Port 0? Bold choice, but no. Try 1-65535.";
164pub const HOST_VAULT_ROLE_INVALID: &str = "Vault SSH role: only letters, digits, /, _ and - \
165 are allowed (e.g. ssh-client-signer/sign/my-role).";
166pub const HOST_VAULT_ADDR_INVALID: &str = "Vault SSH address: must be a non-empty URL \
167 without spaces or control characters (e.g. http://127.0.0.1:8200).";
168
169pub fn field_control_chars(name: &str) -> String {
172 format!(
173 "{} contains control characters. That's not going to work.",
174 name
175 )
176}
177
178pub const TUNNEL_BIND_PORT_INVALID: &str = "Bind port must be 1-65535.";
181pub const TUNNEL_BIND_PORT_ZERO: &str = "Bind port can't be 0.";
182pub const TUNNEL_REMOTE_HOST_EMPTY: &str = "Remote host can't be empty.";
183pub const TUNNEL_REMOTE_HOST_SPACES: &str = "Remote host can't contain spaces.";
184pub const TUNNEL_REMOTE_PORT_INVALID: &str = "Remote port must be 1-65535.";
185pub const TUNNEL_REMOTE_PORT_ZERO: &str = "Remote port can't be 0.";
186
187pub fn field_control_chars_short(name: &str) -> String {
190 format!("{} contains control characters.", name)
191}
192
193pub const SNIPPET_NAME_EMPTY: &str = "Snippet name cannot be empty.";
196pub const SNIPPET_NAME_WHITESPACE: &str =
197 "Snippet name cannot have leading or trailing whitespace.";
198pub const SNIPPET_NAME_INVALID_CHARS: &str = "Snippet name cannot contain #, [ or ].";
199pub const SNIPPET_NAME_CONTROL_CHARS: &str = "Snippet name cannot contain control characters.";
200pub const SNIPPET_COMMAND_EMPTY: &str = "Command cannot be empty.";
201pub const SNIPPET_COMMAND_CONTROL_CHARS: &str = "Command cannot contain control characters.";
202pub const SNIPPET_DESCRIPTION_CONTROL_CHARS: &str = "Description contains control characters.";
203
204pub fn pattern_already_exists(alias: &str) -> String {
207 format!("Pattern '{}' already exists.", alias)
208}
209
210pub fn host_alias_already_exists(alias: &str) -> String {
211 format!("'{}' already exists. Aliases must be unique.", alias)
212}
213
214pub const PATTERN_NO_LONGER_EXISTS: &str = "Pattern no longer exists.";
215pub const HOST_NO_LONGER_EXISTS: &str = "Host no longer exists.";
216
217pub fn cert_path_resolve_failed(e: &impl std::fmt::Display) -> String {
218 format!("Failed to resolve cert path: {}", e)
219}
220
221pub fn welcome_aboard(alias: &str) -> String {
224 format!("Welcome aboard, {}!", alias)
225}
226
227pub const BULK_TAG_NO_HOSTS_SELECTED: &str = "No hosts selected.";
230
231pub fn goodbye_host(alias: &str) -> String {
234 format!("Goodbye, {}. We barely knew ye. (u to undo)", alias)
235}
236
237pub fn host_not_found(alias: &str) -> String {
238 format!("Host '{}' not found.", alias)
239}
240
241pub fn siblings_stripped(alias: &str, sibling_count: usize) -> String {
245 if sibling_count == 1 {
246 format!(
247 "Stripped {}. 1 sibling alias kept its shared config.",
248 alias
249 )
250 } else {
251 format!(
252 "Stripped {}. {} sibling aliases kept their shared config.",
253 alias, sibling_count
254 )
255 }
256}
257
258pub fn confirm_delete_siblings_note(siblings: &[String]) -> String {
262 let shown: Vec<&str> = siblings.iter().take(3).map(String::as_str).collect();
263 let tail = if siblings.len() > shown.len() {
264 format!(" +{} more", siblings.len() - shown.len())
265 } else {
266 String::new()
267 };
268 format!("Siblings kept: {}{}", shown.join(", "), tail)
269}
270
271pub fn cert_cleanup_warning(path: &impl std::fmt::Display, e: &impl std::fmt::Display) -> String {
272 format!("Warning: failed to clean up Vault SSH cert {}: {}", path, e)
273}
274
275pub const CLONED_VAULT_CLEARED: &str = "Cloned. Vault SSH role cleared on copy.";
278
279pub const TUNNEL_REMOVED: &str = "Tunnel removed.";
282pub const TUNNEL_SAVED: &str = "Tunnel saved.";
283pub const TUNNEL_NOT_FOUND: &str = "Tunnel not found in config.";
284pub const TUNNEL_INCLUDED_READ_ONLY: &str = "Included host. Tunnels are read-only.";
285pub const TUNNEL_ORIGINAL_NOT_FOUND: &str = "Original tunnel not found in config.";
286pub const TUNNEL_LIST_CHANGED: &str = "Tunnel list changed externally. Press Esc and re-open.";
287pub const TUNNEL_DUPLICATE: &str = "Duplicate tunnel already configured.";
288pub const TUNNEL_NO_EDITABLE_HOSTS: &str = "No editable hosts. Add a host first.";
289pub const TUNNEL_HOST_PICKER_NO_MATCH: &str = "No matches.";
290
291pub const PICKER_NO_HOSTS: &str = "No hosts yet. Add a host first.";
296
297pub fn tunnel_stopped(alias: &str) -> String {
298 format!("Tunnel for {} stopped.", alias)
299}
300
301pub fn tunnel_started(alias: &str) -> String {
302 format!("Tunnel for {} started.", alias)
303}
304
305pub fn tunnel_start_failed(e: &impl std::fmt::Display) -> String {
306 format!("Failed to start tunnel: {}", e)
307}
308
309pub fn pinging_host(alias: &str, show_hint: bool) -> String {
312 if show_hint {
313 format!("Pinging {}... (Shift+P pings all)", alias)
314 } else {
315 format!("Pinging {}...", alias)
316 }
317}
318
319pub fn bastion_not_found(alias: &str) -> String {
320 format!("Bastion {} not found in config.", alias)
321}
322
323pub fn provider_removed(display_name: &str) -> String {
326 format!(
327 "Removed {} configuration. Synced hosts remain in your SSH config.",
328 display_name
329 )
330}
331
332pub fn label_invalid(reason: &str) -> String {
333 format!("Invalid name: {}", reason)
334}
335
336pub const LABEL_MUST_DIFFER: &str = "The two names must be different.";
337
338pub fn label_already_in_use(label: &str) -> String {
339 format!(
340 "A config named '{}' already exists for this provider.",
341 label
342 )
343}
344
345pub const LABEL_MIGRATION_FIELD_CURRENT: &str = " Name for your current config ";
346pub const LABEL_MIGRATION_FIELD_NEW: &str = " Name for the new config ";
347
348pub const EXPAND_TO_REMOVE_CONFIG: &str =
349 "Expand the provider and pick a specific config to remove.";
350
351pub fn provider_not_configured(display_name: &str) -> String {
352 format!("{} is not configured. Nothing to remove.", display_name)
353}
354
355pub fn provider_configure_first(display_name: &str) -> String {
356 format!("Configure {} first. Press Enter to set up.", display_name)
357}
358
359pub fn provider_saved_syncing(display_name: &str) -> String {
360 format!("Saved {} configuration. Syncing...", display_name)
361}
362
363pub fn provider_saved(display_name: &str) -> String {
364 format!("Saved {} configuration.", display_name)
365}
366
367pub fn no_stale_hosts_for(display_name: &str) -> String {
368 format!("No stale hosts for {}.", display_name)
369}
370
371pub fn contains_control_chars(name: &str) -> String {
372 format!("{} contains control characters.", name)
373}
374
375pub const TOKEN_FORMAT_AWS: &str = "Token format: AccessKeyId:SecretAccessKey";
376pub const URL_REQUIRED_PROXMOX: &str = "URL is required for Proxmox VE.";
377pub const PROJECT_REQUIRED_GCP: &str = "Project ID can't be empty. Set your GCP project ID.";
378pub const COMPARTMENT_REQUIRED_OCI: &str =
379 "Compartment can't be empty. Set your OCI compartment OCID.";
380pub const REGIONS_REQUIRED_AWS: &str = "Select at least one AWS region.";
381pub const ZONES_REQUIRED_SCALEWAY: &str = "Select at least one Scaleway zone.";
382pub const SUBSCRIPTIONS_REQUIRED_AZURE: &str = "Enter at least one Azure subscription ID.";
383pub const ALIAS_PREFIX_INVALID: &str =
384 "Alias prefix can't contain spaces or pattern characters (*, ?, [, !).";
385pub const USER_NO_WHITESPACE: &str = "User can't contain whitespace.";
386pub const VAULT_ROLE_FORMAT: &str = "Vault SSH role must be in the form <mount>/sign/<role>.";
387
388pub const PROVIDER_CONFIG_CHANGED_EXTERNALLY: &str =
389 "Provider config changed externally. Press Esc and re-open to pick up changes.";
390pub const PROVIDER_URL_REQUIRES_HTTPS: &str =
391 "URL must start with https://. Toggle Verify TLS off for self-signed certificates.";
392pub const PROVIDER_TOKEN_REQUIRED_GCP: &str =
393 "Token can't be empty. Provide a service account JSON key file path or access token.";
394pub const PROVIDER_TOKEN_REQUIRED_ORACLE: &str =
395 "Token can't be empty. Provide the path to your OCI config file (e.g. ~/.oci/config).";
396
397pub fn provider_token_required(display_name: &str) -> String {
398 format!(
399 "Token can't be empty. Grab one from your {} dashboard.",
400 display_name
401 )
402}
403
404pub fn azure_subscription_id_invalid(sub: &str) -> String {
405 format!(
406 "Invalid subscription ID '{}'. Expected UUID format \
407 (e.g. 12345678-1234-1234-1234-123456789012).",
408 sub
409 )
410}
411
412pub const VAULT_SIGNING_CANCELLED: &str = "Vault SSH signing cancelled.";
415
416pub fn vault_signing_aborted(failed: u32, last_error: Option<&str>) -> String {
421 format!(
422 "Vault SSH signing aborted after {} consecutive failures. Press V to retry. Last error: {}",
423 failed,
424 last_error.unwrap_or("unknown")
425 )
426}
427
428pub fn bulk_tag_apply_status(
436 changed_hosts: usize,
437 added: usize,
438 removed: usize,
439 skipped_included: usize,
440) -> String {
441 let mut parts: Vec<String> = Vec::new();
442 if changed_hosts > 0 {
443 let host_word = if changed_hosts == 1 { "" } else { "s" };
444 let mut head = format!("Updated {} host{}", changed_hosts, host_word);
445 let mut delta = Vec::new();
446 if added > 0 {
447 delta.push(format!("+{}", added));
448 }
449 if removed > 0 {
450 delta.push(format!("-{}", removed));
451 }
452 if !delta.is_empty() {
453 head = format!("{} ({})", head, delta.join(" "));
454 }
455 parts.push(head);
456 }
457 if skipped_included > 0 {
458 let file_word = if skipped_included == 1 { "" } else { "s" };
459 parts.push(format!(
460 "skipped {} in include file{}",
461 skipped_included, file_word
462 ));
463 }
464 parts.join(". ")
465}
466
467pub fn vault_sign_summary(
468 signed: u32,
469 failed: u32,
470 skipped: u32,
471 first_error: Option<&str>,
472) -> String {
473 let total = signed + failed + skipped;
474 let cert_word = if total == 1 {
475 "certificate"
476 } else {
477 "certificates"
478 };
479 if failed > 0 {
480 if let Some(err) = first_error {
481 if total == 1 {
482 return err.to_string();
483 }
484 format!(
485 "Signed {} of {} {}. {} failed: {}",
486 signed, total, cert_word, failed, err
487 )
488 } else {
489 format!(
490 "Signed {} of {} {}. {} failed",
491 signed, total, cert_word, failed
492 )
493 }
494 } else if skipped > 0 && signed == 0 {
495 format!(
496 "All {} {} already valid. Nothing to sign.",
497 total, cert_word
498 )
499 } else if skipped > 0 {
500 format!(
501 "Signed {} of {} {}. {} already valid.",
502 signed, total, cert_word, skipped
503 )
504 } else {
505 format!("Signed {} of {} {}.", signed, total, cert_word)
506 }
507}
508pub const VAULT_NO_ROLE_CONFIGURED: &str = "No Vault SSH role configured. Set one in the host form \
509 (Vault SSH role field) or on a provider for shared defaults.";
510pub const VAULT_NO_HOSTS_WITH_ROLE: &str = "No hosts with a Vault SSH role configured.";
511pub const VAULT_ALL_CERTS_VALID: &str = "All Vault SSH certificates are still valid.";
512pub const VAULT_NO_ADDRESS: &str = "No Vault address set. Edit the host (e) or provider \
513 and fill in the Vault SSH Address field.";
514
515pub fn vault_error(msg: &str) -> String {
516 format!("Vault SSH: {}", msg)
517}
518
519pub fn vault_signed(alias: &str) -> String {
520 format!("Signed Vault SSH cert for {}", alias)
521}
522
523pub fn vault_sign_failed(alias: &str, message: &str) -> String {
524 format!("Vault SSH: failed to sign {}: {}", alias, message)
525}
526
527pub fn vault_signing_progress(spinner: &str, done: usize, total: usize, alias: &str) -> String {
528 format!(
529 "{} Signing {}/{}: {} (V to cancel)",
530 spinner, done, total, alias
531 )
532}
533
534pub fn vault_cert_saved_host_gone(alias: &str) -> String {
535 format!(
536 "Vault SSH cert saved for {} but host no longer in config \
537 (renamed or deleted). CertificateFile NOT written.",
538 alias
539 )
540}
541
542pub fn vault_spawn_failed(e: &impl std::fmt::Display) -> String {
543 format!("Vault SSH: failed to spawn signing thread: {}", e)
544}
545
546pub fn vault_cert_check_failed(alias: &str, message: &str) -> String {
547 format!("Cert check failed for {}: {}", alias, message)
548}
549
550pub fn vault_role_set(role: &str) -> String {
551 format!("Vault SSH role set to {}.", role)
552}
553
554pub fn vault_signed_pre_connect(alias: &str) -> String {
558 format!("Signed Vault SSH cert for {}.", alias)
559}
560
561pub fn vault_signed_pre_connect_chain(target: &str, count: usize) -> String {
566 if count <= 1 {
567 format!("Signed Vault SSH cert for {}.", target)
568 } else {
569 format!("Signed Vault SSH certs for {} ({} hosts).", target, count)
570 }
571}
572
573pub fn vault_sign_failed_pre_connect(alias: &str, message: &str) -> String {
578 format!("Vault SSH signing failed for {}: {}", alias, message)
579}
580
581pub fn vault_cert_pubkey_resolve_failed(e: &impl std::fmt::Display) -> String {
585 format!("Vault SSH cert failed: {}", e)
586}
587
588pub fn vault_cert_host_block_missing(alias: &str, cert_path: &std::path::Path) -> String {
593 format!(
594 "Warning: signed cert for {} but host block is no longer in ssh config; \
595 CertificateFile not written (cert saved to {})",
596 alias,
597 cert_path.display()
598 )
599}
600
601pub fn vault_cert_config_write_failed(alias: &str, e: &impl std::fmt::Display) -> String {
604 format!(
605 "Warning: signed cert for {} but failed to update SSH config CertificateFile: {}",
606 alias, e
607 )
608}
609
610pub fn snippet_removed(name: &str) -> String {
613 format!("Removed snippet '{}'.", name)
614}
615
616pub fn snippet_added(name: &str) -> String {
617 format!("Added snippet '{}'.", name)
618}
619
620pub fn snippet_updated(name: &str) -> String {
621 format!("Updated snippet '{}'.", name)
622}
623
624pub fn snippet_exists(name: &str) -> String {
625 format!("'{}' already exists.", name)
626}
627
628pub const OUTPUT_COPIED: &str = "Output copied.";
629
630pub fn copy_failed(e: &impl std::fmt::Display) -> String {
631 format!("Copy failed: {}", e)
632}
633
634pub fn clipboard_run_failed(cmd: &str) -> String {
640 format!("Failed to run {}.", cmd)
641}
642
643pub fn clipboard_write_failed(cmd: &str) -> String {
644 format!("Failed to write to {}.", cmd)
645}
646
647pub fn clipboard_wait_failed(cmd: &str) -> String {
648 format!("Failed to wait for {}.", cmd)
649}
650
651pub fn clipboard_exited_error(cmd: &str) -> String {
652 format!("{} exited with error.", cmd)
653}
654
655pub fn import_open_failed(path: &impl std::fmt::Display, e: &impl std::fmt::Display) -> String {
661 format!("Can't open {}: {}", path, e)
662}
663
664pub fn import_known_hosts_open_failed(e: &impl std::fmt::Display) -> String {
665 format!("Can't open known_hosts: {}", e)
666}
667
668pub const IMPORT_HOME_DIR_UNKNOWN: &str = "Could not determine home directory.";
669pub const IMPORT_KNOWN_HOSTS_MISSING: &str = "~/.ssh/known_hosts not found.";
670
671pub fn snippet_ssh_launch_failed(e: &impl std::fmt::Display) -> String {
674 format!("Failed to launch ssh: {}", e)
675}
676
677pub fn vault_create_dir_failed(path: &impl std::fmt::Display) -> String {
684 format!("Failed to create {}", path)
685}
686
687pub fn vault_write_cert_failed(path: &impl std::fmt::Display) -> String {
688 format!("Failed to write certificate to {}", path)
689}
690
691pub fn vault_ssh_keygen_run_failed(e: &impl std::fmt::Display) -> String {
692 format!("Failed to run ssh-keygen: {}", e)
693}
694
695pub const CONTAINER_ID_EMPTY: &str = "Container ID must not be empty.";
702pub const CONTAINER_RUNTIME_MISSING: &str = "No container runtime found. Install Docker or Podman.";
703
704pub fn container_id_invalid_char(c: char) -> String {
705 format!("Container ID contains invalid character: '{c}'")
706}
707
708pub fn container_unknown_sentinel(s: &str) -> String {
709 format!("Unknown sentinel: {s}")
710}
711
712pub fn container_invalid_id(reason: &str) -> String {
713 format!("Container exec blocked: {reason}")
714}
715
716pub fn scp_copying_one(source: &str) -> String {
719 format!("Copying {}...", source)
720}
721
722pub fn scp_copying_many(count: usize) -> String {
725 format!("Copying {} files...", count)
726}
727
728pub fn scp_failed_exit_code(code: i32) -> String {
731 format!("Copy failed (exit code {}).", code)
732}
733
734pub fn scp_spawn_failed(e: &impl std::fmt::Display) -> String {
738 format!("scp failed: {}", e)
739}
740
741pub const GLOBAL_DEFAULT_CLEARED: &str = "Global default cleared.";
744pub const PASSWORD_SOURCE_CLEARED: &str = "Password source cleared.";
745pub const ASKPASS_CUSTOM_COMMAND_HINT: &str =
746 "Type your command. Use %a (alias) and %h (hostname) as placeholders.";
747
748pub fn global_default_set(label: &str) -> String {
749 format!("Global default set to {}.", label)
750}
751
752pub fn password_source_set(label: &str) -> String {
753 format!("Password source set to {}.", label)
754}
755
756pub fn complete_path(label: &str) -> String {
757 format!("Complete the {} path.", label)
758}
759
760pub fn key_selected(name: &str) -> String {
761 format!("Locked and loaded with {}.", name)
762}
763
764pub fn keys_copy_success(name: &str) -> String {
768 format!("Copied {}.pub to clipboard.", name)
769}
770
771pub fn keys_copy_read_failed(name: &str) -> String {
773 format!("Could not read {}.pub from disk.", name)
774}
775
776pub const TAB_EMPTY_HOSTS_HEADLINE: &str = "It's quiet in here.";
783pub const TAB_EMPTY_HOSTS_EXPLAINER: &str = "purple reads hosts from ~/.ssh/config and from the cloud providers you connect. Add one by hand or sync a provider and the list fills up.";
784pub const TAB_EMPTY_HOSTS_HINT_ADD: &str = "add a host";
785pub const TAB_EMPTY_HOSTS_HINT_SYNC: &str = "open providers to sync from the cloud";
786
787pub const TAB_EMPTY_CONTAINERS_HEADLINE: &str = "No containers cached yet.";
788pub const TAB_EMPTY_CONTAINERS_EXPLAINER: &str = "purple snapshots docker or podman output per host and caches it locally. Pick a host below and its containers show up here.";
789pub const TAB_EMPTY_CONTAINERS_HINT_ADD: &str = "pick a host to scan";
790
791pub const TAB_EMPTY_TUNNELS_HEADLINE: &str = "No tunnels yet.";
792pub const TAB_EMPTY_TUNNELS_EXPLAINER: &str = "Tunnels are SSH port forwards stored per host in ~/.ssh/config. This tab aggregates Local, Remote and Dynamic forwards across every alias.";
793pub const TAB_EMPTY_TUNNELS_HINT_ADD: &str = "add a tunnel";
794
795pub const TAB_EMPTY_KEYS_HEADLINE: &str = "No SSH keys in ~/.ssh/ yet.";
796pub const TAB_EMPTY_KEYS_EXPLAINER: &str = "purple reads every public-key file in ~/.ssh/ along with its activity history. Generate one and the new key shows up here on next refresh.";
797pub const TAB_EMPTY_KEYS_HINT_KEYGEN: &str = "ssh-keygen -t ed25519 -C \"$(whoami)@$(hostname)\"";
798
799pub const CONFIRM_TUNNEL_DELETE_TITLE: &str = " Remove tunnel? ";
806pub const CONFIRM_TUNNEL_DELETE_QUESTION: &str = "Remove the selected tunnel rule from this host?";
807pub const CONFIRM_TUNNEL_DELETE_DETAIL: &str =
808 "Rewrites ~/.ssh/config. The rule is gone after save.";
809
810pub const CONFIRM_SNIPPET_DELETE_TITLE: &str = " Remove snippet? ";
811pub const CONFIRM_SNIPPET_DELETE_DETAIL: &str = "The snippet file is rewritten on disk.";
812pub fn confirm_snippet_delete_question(name: &str) -> String {
813 format!("Remove \"{}\" from the snippet store?", name)
814}
815
816pub const CONFIRM_PROVIDER_REMOVE_TITLE: &str = " Remove provider? ";
817pub const CONFIRM_PROVIDER_REMOVE_DETAIL: &str =
818 "Synced hosts stay in ~/.ssh/config. The integration is gone after save.";
819pub fn confirm_provider_remove_question(display: &str) -> String {
820 format!("Remove the \"{}\" provider config?", display)
821}
822pub fn confirm_provider_remove_labeled_question(display: &str, label: &str) -> String {
823 format!("Remove the \"{}\" config labelled \"{}\"?", display, label)
824}
825
826pub const KEY_PUSH_NO_HOSTS: &str =
829 "No hosts in ~/.ssh/config. Add a host first, then come back here.";
830
831pub const VAULT_STRIP_EMPTY: &str =
834 " No active certs. Press V to sign all Vault SSH hosts at once.";
835
836pub const KEY_PUSH_VAULT_TAG: &str = " (vault)";
839
840pub fn key_push_picker_title_eligible(key_label: &str, eligible: usize, total: usize) -> String {
842 format!(
843 "Push {} \u{203A} Select Hosts ({} eligible of {})",
844 key_label, eligible, total
845 )
846}
847
848pub fn key_push_picker_title_selected(
849 key_label: &str,
850 selected: usize,
851 total: usize,
852 eligible: usize,
853) -> String {
854 format!(
855 "Push {} \u{203A} {} selected of {} ({} eligible)",
856 key_label, selected, total, eligible
857 )
858}
859
860pub fn key_push_no_pubkey(name: &str) -> String {
862 format!(
863 "Cannot read {}.pub. The file is missing or unreadable.",
864 name
865 )
866}
867
868pub const KEY_PUSH_NONE_SELECTED: &str = "Select at least one host with Space.";
870
871pub const KEY_PUSH_VAULT_SKIP: &str =
875 "Vault SSH host. Use V on the host list to sign a cert instead.";
876
877pub fn key_push_in_progress(key_name: &str, host_count: usize) -> String {
879 format!("Pushing {} to {} host(s)...", key_name, host_count)
880}
881
882pub fn key_push_thread_spawn_failed() -> String {
884 "Could not spawn push worker thread. Check resource limits.".to_string()
885}
886
887pub const KEY_PUSH_ALREADY_IN_PROGRESS: &str =
890 "A push is already running. Press Esc to cancel first.";
891
892pub fn key_push_pubkey_not_regular(name: &str) -> String {
896 format!("{}.pub is not a regular file. Symlinks are rejected.", name)
897}
898
899pub fn key_push_pubkey_too_large(name: &str, bytes: u64) -> String {
903 format!(
904 "{}.pub is {} bytes, larger than the 16 KiB push limit.",
905 name, bytes
906 )
907}
908
909pub fn key_push_invalid_pubkey(name: &str, detail: &str) -> String {
914 format!("{}.pub failed validation: {}. Push aborted.", name, detail)
915}
916
917pub const KEY_PUSH_NO_HOSTS_SELECTED: &str =
921 "Picker committed with no eligible hosts. Push aborted.";
922
923pub const KEY_PUSH_CERT_NOT_PUSHABLE: &str =
927 "Certificates cannot be pushed as static keys. Sign with V instead.";
928
929pub fn key_push_cancelled(done: usize, total: usize) -> String {
933 format!(
934 "Push cancelled after {} of {} host(s). Re-run to finish the rest.",
935 done, total,
936 )
937}
938
939pub fn key_push_confirm_body(key_name: &str, host_count: usize) -> String {
941 if host_count == 1 {
942 format!("Push {} to 1 host?", key_name)
943 } else {
944 format!("Push {} to {} hosts?", key_name, host_count)
945 }
946}
947
948pub fn key_push_success(appended: usize, already: usize) -> String {
950 if appended == 0 && already > 0 {
951 format!("Key already present on {} host(s). Nothing to do.", already)
952 } else if already == 0 {
953 format!("Pushed to {} host(s).", appended)
954 } else {
955 format!(
956 "Pushed to {} host(s). Already present on {}.",
957 appended, already
958 )
959 }
960}
961
962pub fn key_push_partial_failure(succeeded: usize, failed: usize) -> String {
965 format!("Pushed to {} host(s). {} failed.", succeeded, failed)
966}
967
968pub fn key_push_all_failed(count: usize) -> String {
970 format!(
971 "Push failed for all {} host(s). Check the host log for details.",
972 count
973 )
974}
975
976pub fn proxy_jump_set(alias: &str) -> String {
977 format!("Jumping through {}.", alias)
978}
979
980pub fn save_default_failed(e: &impl std::fmt::Display) -> String {
981 format!("Failed to save default: {}", e)
982}
983
984pub fn container_action_complete(action: &str) -> String {
987 format!("Container {} complete.", action)
988}
989
990pub const HOST_KEY_UNKNOWN: &str = "Host key unknown. Connect first (Enter) to trust the host.";
991pub const HOST_KEY_CHANGED: &str =
992 "Host key changed. Possible tampering or server re-install. Clear with ssh-keygen -R.";
993
994pub const CONTAINER_RUNTIME_NOT_FOUND: &str = "Docker or Podman not found on remote host.";
998pub const CONTAINER_PERMISSION_DENIED: &str =
999 "Permission denied. Is your user in the docker group?";
1000pub const CONTAINER_DAEMON_NOT_RUNNING: &str = "Container daemon is not running.";
1001pub const CONTAINER_CONNECTION_REFUSED: &str = "Connection refused.";
1002pub const CONTAINER_HOST_UNREACHABLE: &str = "Host unreachable.";
1003
1004pub fn container_command_failed(code: i32) -> String {
1008 format!("Command failed with code {}.", code)
1009}
1010
1011pub const CONTAINER_INSPECT_EMPTY: &str = "Inspect returned no data.";
1013
1014pub fn container_inspect_parse_failed(reason: &str) -> String {
1016 format!("Inspect parse failed: {}", reason)
1017}
1018
1019pub fn container_not_running(name: &str) -> String {
1023 format!("{} is not running. Cannot exec.", name)
1024}
1025
1026pub const DEMO_CONTAINER_EXEC_DISABLED: &str = "Demo mode: container exec disabled.";
1028
1029pub fn container_exec_opened_in_tmux(name: &str, alias: &str) -> String {
1031 format!("Opened {} on {} in tmux window.", name, alias)
1032}
1033
1034pub fn container_exec_ended(name: &str) -> String {
1036 format!("Container shell ended: {}.", name)
1037}
1038
1039pub fn container_exec_failed_with_reason(name: &str, reason: &str) -> String {
1041 format!("Container exec failed for {}: {}", name, reason)
1042}
1043
1044pub fn container_exec_exited_with_code(name: &str, code: i32) -> String {
1046 format!("Container exec for {} exited with code {}.", name, code)
1047}
1048
1049pub fn container_exec_spawn_failed(name: &str) -> String {
1051 format!("Failed to launch ssh for container {}.", name)
1052}
1053
1054pub const CONTAINER_EXEC_INVALID_COMMAND: &str =
1056 "Command rejected: control characters not allowed.";
1057
1058pub const CONTAINER_LOGS_LOADING: &str = "fetching logs…";
1062
1063pub fn container_logs_fetched(secs_ago: u64) -> String {
1066 format!(
1067 "fetched {} ago",
1068 crate::containers::format_uptime_short(secs_ago)
1069 )
1070}
1071
1072pub fn container_logs_failed(reason: &str) -> String {
1074 format!("logs fetch failed: {}", reason)
1075}
1076
1077pub fn container_logs_search_position(current: usize, total: usize) -> String {
1080 format!("{} of {}", current, total)
1081}
1082
1083pub const CONTAINER_LOGS_SEARCH_NO_MATCHES: &str = "no matches";
1085
1086pub const CONTAINER_RESTART_BODY: &str =
1090 "Sends SIGTERM, waits 10s, then SIGKILL. Live connections will drop.";
1091pub const CONTAINER_STOP_BODY: &str = "Sends SIGTERM, waits 10s, then SIGKILL. Container will not restart unless its policy reschedules it.";
1092
1093pub fn container_stack_unknown(name: &str) -> String {
1096 format!("Stack unknown for {}: open the detail panel first.", name)
1097}
1098
1099pub fn container_stack_no_running(project: &str) -> String {
1100 format!("Stack {} has no running members to restart.", project)
1101}
1102
1103pub const CONTAINER_STACK_RESTART_BODY: &str = "Restart cycles every running member one by one. Exited members are not touched. Live connections will drop.";
1104
1105pub const CONTAINER_HOST_RESTART_ALL_BODY: &str = "Restart cycles every running container on the host one by one. Exited containers are not touched. Live connections will drop.";
1111
1112pub const CONTAINER_HOST_STOP_ALL_BODY: &str = "Stops every running container on the host one by one. Exited containers are not touched. Restart policies may reschedule them.";
1114
1115pub fn container_action_needs_single(action: &str) -> String {
1121 format!(
1122 "{} need a single container. Place the cursor on a container row.",
1123 action.to_lowercase()
1124 )
1125}
1126
1127pub fn container_host_no_running(alias: &str) -> String {
1129 format!("No running containers on {}.", alias)
1130}
1131
1132pub fn container_refreshing(alias: &str) -> String {
1136 format!("Refreshing {}…", alias)
1137}
1138
1139pub const REFRESH_BATCH_ALREADY_RUNNING: &str = "Refresh already in progress.";
1141
1142pub const REFRESH_NOTHING_TO_REFRESH: &str = "No cached hosts to refresh. Press 'a' to add a host.";
1144
1145pub fn container_refresh_progress(done: usize, total: usize) -> String {
1147 format!("Refreshing {}/{} hosts…", done, total)
1148}
1149
1150pub fn container_refresh_complete(total: usize) -> String {
1152 format!(
1153 "Refreshed {} host{}.",
1154 total,
1155 if total == 1 { "" } else { "s" }
1156 )
1157}
1158
1159pub const CONTAINER_HOST_PICKER_NO_MATCH: &str = "No hosts match.";
1161
1162pub const CONTAINER_HOST_PICKER_NOTHING_TO_ADD: &str =
1164 "All hosts already cached. Use 'r' or 'R' to refresh.";
1165
1166pub fn imported_hosts(imported: usize, skipped: usize) -> String {
1169 format!(
1170 "Imported {} host{}, skipped {} duplicate{}.",
1171 imported,
1172 if imported == 1 { "" } else { "s" },
1173 skipped,
1174 if skipped == 1 { "" } else { "s" }
1175 )
1176}
1177
1178pub fn all_hosts_exist(skipped: usize) -> String {
1179 if skipped == 1 {
1180 "Host already exists.".to_string()
1181 } else {
1182 format!("All {} hosts already exist.", skipped)
1183 }
1184}
1185
1186pub fn config_repaired(groups: usize, orphaned: usize) -> String {
1189 format!(
1190 "Repaired SSH config ({} absorbed, {} orphaned group headers).",
1191 groups, orphaned
1192 )
1193}
1194
1195pub fn no_exact_match(alias: &str) -> String {
1196 format!("No exact match for '{}'. Here's what we found.", alias)
1197}
1198
1199pub fn group_pref_reset_failed(e: &impl std::fmt::Display) -> String {
1200 format!("Group preference reset. (save failed: {})", e)
1201}
1202
1203pub fn opened_in_tmux(alias: &str) -> String {
1206 format!("Opened {} in new tmux window.", alias)
1207}
1208
1209pub fn tmux_error(e: &impl std::fmt::Display) -> String {
1210 format!("tmux: {}", e)
1211}
1212
1213pub fn connection_failed(alias: &str) -> String {
1214 format!("Connection to {} failed.", alias)
1215}
1216
1217pub fn connection_spawn_failed(e: &impl std::fmt::Display) -> String {
1221 format!("Connection failed: {}", e)
1222}
1223
1224pub fn ssh_failed_with_reason(alias: &str, reason: &str) -> String {
1227 format!("SSH to {} failed. {}", alias, reason)
1228}
1229
1230pub fn ssh_exited_with_code(alias: &str, code: i32) -> String {
1233 format!("SSH to {} exited with code {}.", alias, code)
1234}
1235
1236pub fn host_key_remove_failed(stderr: &str) -> String {
1239 format!("Failed to remove host key: {}", stderr)
1240}
1241
1242pub fn ssh_keygen_failed(e: &impl std::fmt::Display) -> String {
1243 format!("Failed to run ssh-keygen: {}", e)
1244}
1245
1246pub const TRANSFER_COMPLETE: &str = "Transfer complete.";
1249
1250pub fn provider_progress(spinner: &str, name: &str, message: &str) -> String {
1259 format!("{} {}: {}", spinner, name, message)
1260}
1261
1262pub const AGE_JUST_NOW: &str = "just now";
1265
1266pub fn relative_age(elapsed: std::time::Duration) -> String {
1270 let secs = elapsed.as_secs();
1271 if secs < 5 {
1272 AGE_JUST_NOW.to_string()
1273 } else if secs < 60 {
1274 format!("{}s ago", secs)
1275 } else if secs < 3600 {
1276 format!("{}m ago", secs / 60)
1277 } else if secs < 86400 {
1278 format!("{}h ago", secs / 3600)
1279 } else {
1280 format!("{}d ago", secs / 86400)
1281 }
1282}
1283
1284pub fn vault_config_reapply_failed(signed: usize, e: &impl std::fmt::Display) -> String {
1287 format!(
1288 "External edits detected; signed {} certs but failed to re-apply CertificateFile: {}",
1289 signed, e
1290 )
1291}
1292
1293pub fn vault_external_edits_merged(summary: &str, reapplied: usize) -> String {
1294 format!(
1295 "{} External ssh config edits detected, merged {} CertificateFile directives.",
1296 summary, reapplied
1297 )
1298}
1299
1300pub fn vault_external_edits_no_write(summary: &str) -> String {
1301 format!(
1302 "{} External ssh config edits detected; certs on disk, no CertificateFile written.",
1303 summary
1304 )
1305}
1306
1307pub fn vault_reparse_failed(signed: usize, e: &impl std::fmt::Display) -> String {
1308 format!(
1309 "Signed {} certs but cannot re-parse ssh config after external edit: {}. \
1310 Certs are on disk under ~/.purple/certs/.",
1311 signed, e
1312 )
1313}
1314
1315pub fn vault_config_update_failed(signed: usize, e: &impl std::fmt::Display) -> String {
1316 format!(
1317 "Signed {} certs but failed to update SSH config: {}",
1318 signed, e
1319 )
1320}
1321
1322pub fn vault_config_write_after_sign(e: &impl std::fmt::Display) -> String {
1323 format!("Failed to update config after vault signing: {}", e)
1324}
1325
1326pub fn vault_config_skipped_external_change() -> &'static str {
1327 "Config changed on disk since signing started. Cert files are saved; re-run vault sign to wire them up."
1328}
1329
1330pub fn sync_skipped_external_change() -> &'static str {
1331 "Config changed on disk during sync. Re-run sync after reviewing your edits."
1332}
1333
1334pub fn removed_host_key(hostname: &str) -> String {
1339 format!("Removed host key for {}. Reconnecting...", hostname)
1340}
1341
1342pub fn tagged_host(alias: &str, count: usize) -> String {
1345 format!(
1346 "Tagged {} with {} label{}.",
1347 alias,
1348 count,
1349 if count == 1 { "" } else { "s" }
1350 )
1351}
1352
1353pub fn config_reloaded(count: usize) -> String {
1356 format!("Config reloaded. {} hosts.", count)
1357}
1358
1359pub fn synced_progress(
1375 spinner: &str,
1376 active_names: &str,
1377 done: usize,
1378 total: usize,
1379 added: usize,
1380 updated: usize,
1381 stale: usize,
1382) -> String {
1383 debug_assert!(
1384 !active_names.is_empty(),
1385 "synced_progress must only be called while a provider is still in flight"
1386 );
1387 let diff = sync_diff_suffix(added, updated, stale);
1388 format!(
1389 "{} Syncing {} \u{00B7} {}/{}{}",
1390 spinner, active_names, done, total, diff
1391 )
1392}
1393
1394pub fn synced_done(
1399 done: usize,
1400 total: usize,
1401 names: &str,
1402 added: usize,
1403 updated: usize,
1404 stale: usize,
1405) -> String {
1406 let diff = sync_diff_suffix(added, updated, stale);
1407 format!("Synced {}/{} \u{00B7} {}{}", done, total, names, diff)
1408}
1409
1410fn sync_diff_suffix(added: usize, updated: usize, stale: usize) -> String {
1411 let parts: Vec<String> = [(added, '+'), (updated, '~'), (stale, '-')]
1412 .iter()
1413 .filter(|(n, _)| *n > 0)
1414 .map(|(n, sign)| format!("{}{}", sign, n))
1415 .collect();
1416 if parts.is_empty() {
1417 String::new()
1418 } else {
1419 format!(" ({})", parts.join(" "))
1420 }
1421}
1422
1423pub const SYNC_THREAD_SPAWN_FAILED: &str = "Failed to start sync thread.";
1424
1425pub const SYNC_UNKNOWN_PROVIDER: &str = "Unknown provider.";
1426
1427pub fn vault_signing_cancelled_summary(
1430 signed: u32,
1431 failed: u32,
1432 first_error: Option<&str>,
1433) -> String {
1434 let mut msg = format!(
1435 "Vault SSH signing cancelled ({} signed, {} failed)",
1436 signed, failed
1437 );
1438 if let Some(err) = first_error {
1439 msg.push_str(": ");
1440 msg.push_str(err);
1441 }
1442 msg
1443}
1444
1445pub fn regions_selected_count(count: usize, label: &str) -> String {
1448 let s = if count == 1 { "" } else { "s" };
1449 format!("{} {}{} selected.", count, label, s)
1450}
1451
1452pub const NO_CLIPBOARD_TOOL: &str =
1457 "No clipboard tool found. Install pbcopy (macOS), wl-copy (Wayland), or xclip/xsel (X11).";
1458
1459pub const MCP_TOOL_DENIED_READ_ONLY: &str = "Tool denied. Server started with --read-only. Restart without --read-only to enable state-changing tools.";
1462
1463pub fn mcp_audit_init_failed(path: &impl std::fmt::Display, e: &impl std::fmt::Display) -> String {
1467 format!(
1468 "Failed to initialise MCP audit log at {}: {}. Continuing without audit logging.",
1469 path, e
1470 )
1471}
1472
1473pub fn mcp_audit_write_failed(e: &impl std::fmt::Display) -> String {
1475 format!("Failed to write MCP audit entry: {}", e)
1476}
1477
1478pub fn mcp_config_file_not_found(path: &impl std::fmt::Display) -> String {
1482 format!("SSH config file not found: {}", path)
1483}
1484
1485pub const MCP_AUDIT_HOME_DIR_UNAVAILABLE: &str = "Could not determine home directory; MCP audit log disabled. Set --audit-log <PATH> explicitly to enable auditing.";
1489
1490pub const PALETTE_PLACEHOLDER: &str = "Find anything";
1494pub const PALETTE_NO_RESULTS: &str = "No matches.";
1496pub const PALETTE_SNIPPET_NEEDS_HOST: &str =
1499 "Pick a host first, then run a snippet from the jump bar.";
1500pub fn jump_more_rows(n: usize) -> String {
1503 format!("+{n} more (scroll down)")
1504}
1505
1506#[path = "messages/cli.rs"]
1509pub mod cli;
1510pub mod footer;
1511
1512pub mod update {
1515 pub const WHATS_NEW_HINT: &str = "Press n inside purple to see what's new.";
1516 pub const DONE: &str = "done.";
1517 pub const CHECKSUM_OK: &str = "ok.";
1518 pub const SUDO_WARNING: &str =
1519 "Running via sudo. Consider fixing directory permissions instead.";
1520
1521 pub const STEP_CHECKING: &str = " Checking for updates... ";
1526 pub const STEP_VERIFYING_CHECKSUM: &str = " Verifying checksum... ";
1527 pub const STEP_INSTALLING: &str = " Installing... ";
1528
1529 pub fn already_on(current: &str) -> String {
1530 format!("already on v{} (latest).", current)
1531 }
1532
1533 pub fn available(latest: &str, current: &str) -> String {
1534 format!("v{} available (current: v{}).", latest, current)
1535 }
1536
1537 pub fn step_downloading(version: &str) -> String {
1541 format!(" Downloading v{}... ", version)
1542 }
1543
1544 pub fn sudo_warning_line(bold_bang: &str) -> String {
1548 format!(" {} {}", bold_bang, SUDO_WARNING)
1549 }
1550
1551 pub fn header(bold_name: &str) -> String {
1552 format!("\n {} updater\n", bold_name)
1553 }
1554
1555 pub fn binary_path(path: &std::path::Path) -> String {
1556 format!(" Binary: {}", path.display())
1557 }
1558
1559 pub fn installed_at(bold_version: &str, path: &std::path::Path) -> String {
1560 format!("\n {} installed at {}.", bold_version, path.display())
1561 }
1562
1563 pub fn whats_new_hint_indented() -> String {
1564 format!("\n {}", WHATS_NEW_HINT)
1565 }
1566}
1567
1568pub mod askpass {
1571 pub const BW_NOT_FOUND: &str = "Bitwarden CLI (bw) not found. SSH will prompt for password.";
1572 pub const BW_NOT_LOGGED_IN: &str = "Bitwarden vault not logged in. Run 'bw login' first.";
1573 pub const EMPTY_PASSWORD: &str = "Empty password. SSH will prompt for password.";
1574 pub const PASSWORD_IN_KEYCHAIN: &str = "Password stored in keychain.";
1575
1576 pub fn read_failed(e: &impl std::fmt::Display) -> String {
1577 format!("Failed to read password: {}", e)
1578 }
1579
1580 pub fn unlock_failed_retry(e: &impl std::fmt::Display) -> String {
1581 format!("Unlock failed: {}. Try again.", e)
1582 }
1583
1584 pub fn unlock_failed_prompt(e: &impl std::fmt::Display) -> String {
1585 format!("Unlock failed: {}. SSH will prompt for password.", e)
1586 }
1587
1588 pub fn password_prompt(alias: &str) -> String {
1592 format!("Password for {}: ", alias)
1593 }
1594
1595 pub fn keychain_password_prompt(alias: &str) -> String {
1598 format!("Password for {} (stored in keychain): ", alias)
1599 }
1600
1601 pub fn keychain_store_failed(e: &impl std::fmt::Display) -> String {
1604 format!(
1605 "Failed to store in keychain: {}. SSH will prompt for password.",
1606 e
1607 )
1608 }
1609
1610 pub const PROTON_NOT_FOUND: &str =
1611 "Proton Pass CLI (pass-cli) not found. SSH will prompt for password.";
1612
1613 pub const PROTON_LOGIN_PROMPT: &str = "Proton Pass PAT: ";
1614
1615 pub const PROTON_LOGIN_SUCCESS: &str = "Logged in to Proton Pass.";
1616
1617 pub fn proton_login_failed_retry(e: &impl std::fmt::Display) -> String {
1618 format!("Proton Pass login failed: {}. Try again.", e)
1619 }
1620
1621 pub fn proton_login_failed_prompt(e: &impl std::fmt::Display) -> String {
1622 format!(
1623 "Proton Pass login failed: {}. SSH will prompt for password.",
1624 e
1625 )
1626 }
1627}
1628
1629pub mod logging {
1632 pub fn init_failed(e: &impl std::fmt::Display) -> String {
1633 format!("[purple] Failed to initialize logger: {}", e)
1634 }
1635
1636 pub const SSH_VERSION_FAILED: &str = "[purple] Failed to detect SSH version. Is ssh installed?";
1637}
1638
1639pub mod hints {
1645 pub const IDENTITY_FILE_PICK: &str = "Space to pick a key";
1650 pub const DEFAULT_SSH_USER: &str = "root";
1651
1652 pub const HOST_ALIAS: &str = "e.g. prod or db-01";
1654 pub const HOST_ALIAS_PATTERN: &str = "10.0.0.* or *.example.com";
1655 pub const HOST_HOSTNAME: &str = "192.168.1.1 or example.com";
1656 pub const HOST_PORT: &str = "22";
1657 pub const HOST_PROXY_JUMP: &str = "Space to pick a host";
1658 pub const HOST_VAULT_SSH: &str = "e.g. ssh-client-signer/sign/my-role (auth via vault login)";
1659 pub const HOST_VAULT_SSH_PICKER: &str = "Space to pick a role or type one";
1660 pub const HOST_VAULT_ADDR: &str =
1661 "e.g. http://127.0.0.1:8200 (inherits from provider or env when empty)";
1662 pub const HOST_TAGS: &str = "e.g. prod, staging, us-east (comma-separated)";
1663 pub const HOST_ASKPASS_PICK: &str = "Space to pick a source";
1664
1665 pub fn askpass_default(default: &str) -> String {
1666 format!("default: {}", default)
1667 }
1668
1669 pub fn inherits_from(value: &str, provider: &str) -> String {
1670 format!("inherits {} from {}", value, provider)
1671 }
1672
1673 pub const TUNNEL_BIND_PORT: &str = "8080";
1675 pub const TUNNEL_REMOTE_HOST: &str = "localhost";
1676 pub const TUNNEL_REMOTE_PORT: &str = "80";
1677
1678 pub const SNIPPET_NAME: &str = "check-disk";
1680 pub const SNIPPET_COMMAND: &str = "df -h";
1681 pub const SNIPPET_OPTIONAL: &str = "(optional)";
1682
1683 pub const PROVIDER_URL: &str = "https://pve.example.com:8006";
1685 pub const PROVIDER_TOKEN_DEFAULT: &str = "your-api-token";
1686 pub const PROVIDER_TOKEN_PROXMOX: &str = "user@pam!token=secret";
1687 pub const PROVIDER_TOKEN_AWS: &str = "AccessKeyId:Secret (or use Profile)";
1688 pub const PROVIDER_TOKEN_GCP: &str = "/path/to/service-account.json (or access token)";
1689 pub const PROVIDER_TOKEN_AZURE: &str = "/path/to/service-principal.json (or access token)";
1690 pub const PROVIDER_TOKEN_TAILSCALE: &str = "API key (leave empty for local CLI)";
1691 pub const PROVIDER_TOKEN_ORACLE: &str = "~/.oci/config";
1692 pub const PROVIDER_TOKEN_OVH: &str = "app_key:app_secret:consumer_key";
1693 pub const PROVIDER_PROFILE: &str = "Name from ~/.aws/credentials (or use Token)";
1694 pub const PROVIDER_PROJECT_DEFAULT: &str = "my-gcp-project-id";
1695 pub const PROVIDER_PROJECT_OVH: &str = "Public Cloud project ID";
1696 pub const PROVIDER_COMPARTMENT: &str = "ocid1.compartment.oc1..aaaa...";
1697 pub const PROVIDER_REGIONS_DEFAULT: &str = "Space to select regions";
1698 pub const PROVIDER_REGIONS_GCP: &str = "Space to select zones (empty = all)";
1699 pub const PROVIDER_REGIONS_SCALEWAY: &str = "Space to select zones";
1700 pub const PROVIDER_REGIONS_AZURE: &str = "comma-separated subscription IDs";
1702 pub const PROVIDER_REGIONS_OVH: &str = "Space to select endpoint (default: EU)";
1703 pub const PROVIDER_USER_AWS: &str = "ec2-user";
1704 pub const PROVIDER_USER_GCP: &str = "ubuntu";
1705 pub const PROVIDER_USER_AZURE: &str = "azureuser";
1706 pub const PROVIDER_USER_ORACLE: &str = "opc";
1707 pub const PROVIDER_USER_OVH: &str = "ubuntu";
1708 pub const PROVIDER_VAULT_ROLE: &str =
1709 "e.g. ssh-client-signer/sign/my-role (vault login; inherited)";
1710 pub const PROVIDER_VAULT_ADDR: &str = "e.g. http://127.0.0.1:8200 (inherited by all hosts)";
1711 pub const PROVIDER_ALIAS_PREFIX_DEFAULT: &str = "prefix";
1712 pub const PROVIDER_LABEL: &str = "short name, e.g. server1 or work";
1713}
1714
1715#[cfg(test)]
1716mod hints_tests {
1717 use super::hints;
1718
1719 #[test]
1720 fn askpass_default_formats() {
1721 assert_eq!(hints::askpass_default("keychain"), "default: keychain");
1722 }
1723
1724 #[test]
1725 fn askpass_default_formats_empty() {
1726 assert_eq!(hints::askpass_default(""), "default: ");
1727 }
1728
1729 #[test]
1730 fn inherits_from_formats() {
1731 assert_eq!(
1732 hints::inherits_from("role/x", "aws"),
1733 "inherits role/x from aws"
1734 );
1735 }
1736
1737 #[test]
1738 fn picker_hints_mention_space_not_enter() {
1739 for s in [
1742 hints::IDENTITY_FILE_PICK,
1743 hints::HOST_PROXY_JUMP,
1744 hints::HOST_VAULT_SSH_PICKER,
1745 hints::HOST_ASKPASS_PICK,
1746 hints::PROVIDER_REGIONS_DEFAULT,
1747 hints::PROVIDER_REGIONS_GCP,
1748 hints::PROVIDER_REGIONS_SCALEWAY,
1749 hints::PROVIDER_REGIONS_OVH,
1750 ] {
1751 assert!(
1752 s.starts_with("Space "),
1753 "picker hint must mention Space: {s}"
1754 );
1755 assert!(!s.contains("Enter "), "picker hint must not say Enter: {s}");
1756 }
1757 }
1758}
1759
1760#[path = "messages/whats_new.rs"]
1761pub mod whats_new;
1762
1763#[path = "messages/whats_new_toast.rs"]
1764pub mod whats_new_toast;
1765
1766#[cfg(test)]
1767mod stale_host_tests {
1768 use super::stale_host;
1769
1770 #[test]
1771 fn empty_hint_returns_bare_sentence() {
1772 assert_eq!(stale_host(""), "Stale host.");
1773 }
1774
1775 #[test]
1776 fn empty_after_trim_returns_bare_sentence() {
1777 assert_eq!(stale_host(" "), "Stale host.");
1778 }
1779
1780 #[test]
1781 fn provider_hint_is_appended_with_space_and_period() {
1782 assert_eq!(
1783 stale_host("Gone from DigitalOcean"),
1784 "Stale host. Gone from DigitalOcean."
1785 );
1786 }
1787
1788 #[test]
1789 fn trailing_period_in_hint_is_not_doubled() {
1790 assert_eq!(
1791 stale_host("Gone from DigitalOcean."),
1792 "Stale host. Gone from DigitalOcean."
1793 );
1794 }
1795
1796 #[test]
1797 fn leading_space_in_hint_is_trimmed() {
1798 assert_eq!(stale_host(" Gone from AWS"), "Stale host. Gone from AWS.");
1799 }
1800}
1801
1802#[cfg(test)]
1803mod relative_age_tests {
1804 use super::relative_age;
1805 use std::time::Duration;
1806
1807 #[test]
1808 fn relative_age_boundaries() {
1809 assert_eq!(relative_age(Duration::from_secs(0)), "just now");
1810 assert_eq!(relative_age(Duration::from_secs(4)), "just now");
1811 assert_eq!(relative_age(Duration::from_secs(5)), "5s ago");
1812 assert_eq!(relative_age(Duration::from_secs(59)), "59s ago");
1813 assert_eq!(relative_age(Duration::from_secs(60)), "1m ago");
1814 assert_eq!(relative_age(Duration::from_secs(3599)), "59m ago");
1815 assert_eq!(relative_age(Duration::from_secs(3600)), "1h ago");
1816 assert_eq!(relative_age(Duration::from_secs(86399)), "23h ago");
1817 assert_eq!(relative_age(Duration::from_secs(86400)), "1d ago");
1818 assert_eq!(relative_age(Duration::from_secs(86400 * 7)), "7d ago");
1819 }
1820}