1use crate::config::Config;
2use anyhow::Result;
3
4pub mod check;
5pub mod init;
6pub mod migration;
7pub mod test;
8
9pub use check::Check;
10pub use init::Init;
11pub use migration::{
12 AdoptMigration, ApplyMigration, BuildMigration, MigrationStatus, NewMigration, PinMigration,
13};
14pub use test::{BuildTest, CompareTests, ExpectTest, NewTest, RunTest};
15
16#[derive(Debug, Clone, Default)]
18pub struct TelemetryInfo {
19 pub label: String,
22 pub properties: Vec<(&'static str, String)>,
25}
26
27impl TelemetryInfo {
28 pub fn new(label: impl Into<String>) -> Self {
29 Self {
30 label: label.into(),
31 properties: vec![],
32 }
33 }
34
35 pub fn with_properties(mut self, properties: Vec<(&'static str, String)>) -> Self {
36 self.properties = properties;
37 self
38 }
39}
40
41pub trait TelemetryDescribe {
46 fn telemetry(&self) -> TelemetryInfo;
47}
48
49#[allow(async_fn_in_trait)]
51pub trait Command: TelemetryDescribe {
52 async fn execute(&self, config: &Config) -> Result<Outcome>;
53}
54
55pub enum Outcome {
56 AdoptedMigration,
57 AppliedMigrations,
58 BuiltMigration { content: String, pinned_warn: bool },
59 CheckFailed,
60 NewMigration(String),
61 NewTest(String),
62 PinnedMigration { hash: String },
63 Success,
64 Unimplemented,
65}