Skip to main content

changeset_operations/traits/
init_interaction.rs

1use changeset_manifest::{ChangelogLocation, ComparisonLinks, TagFormat, ZeroVersionBehavior};
2
3use crate::Result;
4
5#[derive(Debug, Clone, Copy, Default)]
6pub struct ProjectContext {
7    pub is_single_package: bool,
8}
9
10#[derive(Debug, Clone)]
11pub struct GitSettingsInput {
12    pub commit: bool,
13    pub tags: bool,
14    pub keep_changesets: bool,
15    pub tag_format: TagFormat,
16}
17
18impl Default for GitSettingsInput {
19    fn default() -> Self {
20        Self {
21            commit: true,
22            tags: true,
23            keep_changesets: false,
24            tag_format: TagFormat::default(),
25        }
26    }
27}
28
29#[derive(Debug, Clone, Default)]
30pub struct ChangelogSettingsInput {
31    pub changelog: ChangelogLocation,
32    pub comparison_links: ComparisonLinks,
33}
34
35#[derive(Debug, Clone, Default)]
36pub struct VersionSettingsInput {
37    pub zero_version_behavior: ZeroVersionBehavior,
38}
39
40pub trait InitInteractionProvider: Send + Sync {
41    /// Prompts user to configure git settings. Returns None if user skips this group.
42    ///
43    /// The `context` parameter provides project information (e.g., whether it's a
44    /// single-package project) so the provider can adapt defaults accordingly.
45    ///
46    /// # Errors
47    ///
48    /// Returns an error if the interaction cannot be completed.
49    fn configure_git_settings(&self, context: ProjectContext) -> Result<Option<GitSettingsInput>>;
50
51    /// Prompts user to configure changelog settings. Returns None if user skips this group.
52    ///
53    /// For single-package projects, the changelog location question should be skipped
54    /// (defaulting to root), but `comparison_links` should still be prompted.
55    ///
56    /// # Errors
57    ///
58    /// Returns an error if the interaction cannot be completed.
59    fn configure_changelog_settings(
60        &self,
61        context: ProjectContext,
62    ) -> Result<Option<ChangelogSettingsInput>>;
63
64    /// Prompts user to configure version settings. Returns None if user skips this group.
65    ///
66    /// # Errors
67    ///
68    /// Returns an error if the interaction cannot be completed.
69    fn configure_version_settings(&self) -> Result<Option<VersionSettingsInput>>;
70}