pub mod devices;
pub mod mint;
pub mod pair_ui;
pub mod recovery;
pub mod requests;
use crate::ui::{self, Tone};
pub fn rule() -> &'static str {
"────────────────────────────────────────────────────────────────────────────────"
}
pub fn double_rule() -> &'static str {
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}
fn can_line(ok: bool, deliberate: bool, text: &str) -> String {
if ok && deliberate {
format!(" {} {}", ui::paint(Tone::Warn, ui::glyph_warn()), text)
} else if ok {
format!(" {} {}", ui::paint(Tone::Ok, ui::glyph_ok()), text)
} else {
format!(" {} {}", ui::paint(Tone::Err, ui::glyph_err()), text)
}
}
fn meta(text: &str) -> String {
ui::paint(Tone::Dim, &format!(" {text}"))
}
pub fn confirm_mistype(token: &str) -> String {
format!(
"{} {}",
ui::paint(Tone::Warn, ui::glyph_warn()),
format!("didn't match \"{token}\" — left off.")
)
}
pub fn err_bad_arg(msg: &str) -> String {
format!("{} {msg}", ui::paint(Tone::Err, ui::glyph_err()))
}
pub fn err_refused(msg: &str) -> String {
format!("{} {msg}", ui::paint(Tone::Err, ui::glyph_err()))
}
pub fn echo_cmd(cmd: &str) -> String {
format!("{} {cmd}", ui::paint(Tone::Dim, ui::glyph_echo()))
}
pub const CONFIRM_SHELL: &str = "SHELL";
pub const CONFIRM_WRITE: &str = "WRITE";
pub const CONFIRM_ALL_PORTS: &str = "ALL-PORTS";
pub const CONFIRM_REUSE: &str = "REUSE";
pub const EXIT_BAD_ARG: i32 = 2;
pub const EXIT_REFUSED: i32 = 1;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn confirm_tokens_are_exact() {
assert_eq!(CONFIRM_SHELL, "SHELL");
assert_eq!(CONFIRM_WRITE, "WRITE");
assert_eq!(CONFIRM_ALL_PORTS, "ALL-PORTS");
assert_eq!(CONFIRM_REUSE, "REUSE");
}
#[test]
fn exit_codes() {
assert_eq!(EXIT_BAD_ARG, 2);
assert_eq!(EXIT_REFUSED, 1);
}
}