1pub use interactive_clap_derive::{InteractiveClap, ToCliArgs};
8
9pub trait ToCli {
15 type CliVariant;
16}
17
18impl ToCli for String {
19 type CliVariant = String;
20}
21
22impl ToCli for u128 {
23 type CliVariant = u128;
24}
25
26impl ToCli for u64 {
27 type CliVariant = u64;
28}
29
30impl ToCli for bool {
31 type CliVariant = bool;
32}
33
34pub trait ToInteractiveClapContextScope {
36 type InteractiveClapContextScope;
37}
38
39pub trait ToCliArgs {
40 fn to_cli_args(&self) -> std::collections::VecDeque<String>;
41}
42
43pub enum ResultFromCli<T, E> {
44 Ok(T),
45 Cancel(Option<T>),
46 Back,
47 Err(Option<T>, E),
48}
49
50pub trait FromCli {
55 type FromCliContext;
56 type FromCliError;
57 fn from_cli(
58 optional_clap_variant: Option<<Self as ToCli>::CliVariant>,
59 context: Self::FromCliContext,
60 ) -> ResultFromCli<<Self as ToCli>::CliVariant, Self::FromCliError>
61 where
62 Self: Sized + ToCli;
63}
64
65pub enum SelectVariantOrBack<T: strum::EnumMessage> {
66 Variant(T),
67 Back,
68}
69impl<T: strum::EnumMessage> std::fmt::Display for SelectVariantOrBack<T> {
70 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
71 if let Self::Variant(variant) = self {
72 f.write_str(variant.get_message().unwrap())
73 } else {
74 f.write_str("back")
75 }
76 }
77}