oboron_cli_core/lib.rs
1//! Shared CLI plumbing for the oboron-protocol CLIs (`ob` and `obc`).
2//!
3//! Both binaries share a config directory at `~/.oboron/`:
4//!
5//! ```text
6//! ~/.oboron/
7//! ├── config.json # active profile + per-binary defaults
8//! ├── profiles/<name>.json # per-profile key + metadata
9//! └── bkp/<name>-<ts>.json # automatic backups on overwrite/delete
10//! ```
11//!
12//! This crate provides:
13//!
14//! - **Path resolution** — `config_path`, `profile_dir`, `profile_path`, `backup_dir`.
15//! - **Name validation** — `validate_profile_name`.
16//! - **Key normalization** — `normalize_key_to_hex` accepts the canonical
17//! 128-char hex form *or* the legacy 86-char base64 form (during the
18//! base64 deprecation period) and returns canonical hex.
19//! - **Config / profile I/O** — `load_config`, `save_config`, `load_profile`,
20//! `save_profile`, `list_profiles`, `delete_profile`, `rename_profile`.
21//! File writes preserve unknown JSON fields so the two binaries don't
22//! clobber each other's metadata.
23//! - **Backups** — `backup_profile` saves a timestamped copy before
24//! overwrite/delete.
25//! - **Command handlers** — `commands::*` implements the user-facing
26//! `init` / `config` / `profile` / `key` subcommands shared by both
27//! binaries, parameterized over a [`commands::CliInfo`] supplying the
28//! per-binary defaults and the binary name used in error hints.
29//! - **Legacy-dir migration** — `migration::ensure_config_root_migrated`
30//! moves a leftover `~/.ob/` to `~/.oboron/` on first run of the
31//! current tooling, leaving a symlink so any older binary still
32//! on the system keeps working against the same data.
33
34pub mod commands;
35pub mod config;
36pub mod key;
37pub mod migration;
38pub mod paths;
39pub mod profile;
40
41pub use config::{load_config, save_config, Config};
42pub use key::{normalize_key_classify, normalize_key_to_hex, KeyFormat};
43pub use paths::{backup_dir, config_path, config_root, profile_dir, profile_path};
44pub use profile::{
45 delete_profile, list_profiles, load_profile, load_profile_key, load_profile_key_as_hex,
46 rename_profile, save_profile, validate_profile_name, KeyProfile, LoadedKey,
47};