Skip to content

Commit

Permalink
refactor profilecreator
Browse files Browse the repository at this point in the history
  • Loading branch information
aprxi committed Sep 27, 2024
1 parent 45c2d54 commit 757bd93
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 412 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,39 @@ mod profile;
mod prompt;
mod provider;

use std::fmt;

pub use profile::{ProfileCreationStep, ProfileCreator};
pub use prompt::{PromptCreationStep, PromptCreator};
pub use provider::{ProviderCreationStep, ProviderCreator};

use super::*;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProfileSection {
Provider,
Prompt,
}

impl ProfileSection {
fn as_str(&self) -> &'static str {
match self {
ProfileSection::Provider => "provider",
ProfileSection::Prompt => "prompt",
}
}

fn from_config_tab(tab: &ConfigTab) -> Option<Self> {
match tab {
ConfigTab::Providers => Some(ProfileSection::Provider),
ConfigTab::Prompts => Some(ProfileSection::Prompt),
_ => None,
}
}
}

impl fmt::Display for ProfileSection {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}
}
Loading

0 comments on commit 757bd93

Please sign in to comment.