#[derive(Debug, Clone, serde::Serialize)]
pub struct ProjectProfile {
pub name: String,
pub language: Language,
pub has_cli: bool,
pub cli_command: Option<Vec<String>>,
pub cli_help_output: Option<String>,
#[serde(default)]
pub cli_subcommand_help: Vec<(String, String)>,
#[serde(default, skip_serializing_if = "DiagTrace::is_empty")]
pub diag: DiagTrace,
pub repo_url: Option<String>,
pub license: Option<String>,
pub version: Option<String>,
pub authors: Option<String>,
pub description_hint: Option<String>,
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct DiagNote {
pub stage: &'static str,
pub note: String,
}
#[derive(Debug, Clone, Default, serde::Serialize)]
pub struct DiagTrace(pub Vec<DiagNote>);
impl DiagTrace {
pub fn push(&mut self, stage: &'static str, note: impl Into<String>) {
self.0.push(DiagNote {
stage,
note: note.into(),
});
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Language {
Rust,
Node,
Python,
Go,
Ruby,
Php,
CSharp,
Jvm,
Unknown,
}
impl Language {
pub fn as_str(self) -> &'static str {
match self {
Self::Rust => "rust",
Self::Node => "node",
Self::Python => "python",
Self::Go => "go",
Self::Ruby => "ruby",
Self::Php => "php",
Self::CSharp => "csharp",
Self::Jvm => "jvm",
Self::Unknown => "unknown",
}
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Intent {
pub one_line_description: String,
pub when_to_use_phrases: Vec<String>,
pub invocation_command: Option<String>,
pub import_pattern: Option<String>,
pub author: Option<String>,
pub license: Option<String>,
}
impl Intent {
#[allow(dead_code)]
pub fn is_pure_library(&self) -> bool {
self.invocation_command.is_none()
}
}