1mod args;
2mod boilerplate;
3mod color;
4mod config;
5mod deployments;
6mod encryption;
7mod environment;
8mod errors;
9mod hosts;
10mod logs;
11mod network;
12mod service;
13mod shell;
14mod structures;
15mod support_control;
16mod verbosity;
17
18pub use args::*;
19pub use boilerplate::*;
20pub use color::Color;
21pub use config::*;
22pub use deployments::*;
23pub use encryption::*;
24pub use environment::Environment;
25pub use errors::*;
26pub use hosts::*;
27pub use logs::*;
28pub use network::NetworkConfig;
29pub use service::*;
30pub use shell::*;
31pub use structures::*;
32pub use support_control::SupportControl;
33pub use verbosity::Verbosity;
34
35type TracingTarget = Box<dyn tracing_subscriber::Layer<tracing_subscriber::Registry> + Send + Sync>;
36type TracingTargets = Vec<TracingTarget>;
37
38pub type Result<T> = std::result::Result<T, SupportKitError>;
39
40#[cfg(test)]
41mod tests {
42
43 #[test]
44 fn usage_as_a_library_consumer() -> Result<(), Box<dyn std::error::Error>> {
45 use clap::{Parser, Subcommand};
46
47 #[derive(Parser)]
48 struct LocalCli {
49 #[clap(subcommand)]
50 command: Option<LocalCommand>,
51
52 #[clap(flatten)]
53 support: crate::Args,
54 }
55
56 #[derive(Clone, Copy, Debug, Subcommand, PartialEq)]
57 #[clap(rename_all = "kebab-case")]
58 enum LocalCommand {
59 DoTheThing,
60 }
61
62 let expectations = [
63 ("app", None),
64 ("app do-the-thing", Some(LocalCommand::DoTheThing)),
65 ("app service install", None),
66 ("app service start", None),
67 ("app service stop", None),
68 ("app service uninstall", None),
69 ];
70
71 for (input, expected) in expectations {
72 let cli = LocalCli::try_parse_from(input.split_whitespace())?;
73
74 assert_eq!(cli.command, expected);
75 }
76
77 use crate::{Commands, ServiceCommand::*};
78 let expectations = [
79 ("app", None),
80 ("app do-the-thing", None),
81 (
82 "app service install",
83 Some(Commands::from(Install(Default::default()))),
84 ),
85 ("app service start", Some(Commands::from(Start))),
86 ("app service stop", Some(Commands::from(Stop))),
87 ("app service uninstall", Some(Commands::from(Uninstall))),
88 ];
89
90 for (input, expected) in expectations {
91 let cli = LocalCli::try_parse_from(input.split_whitespace())?;
92
93 assert_eq!(cli.support.command, expected);
94 }
95
96 Ok(())
97 }
98}