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