#[ derive( Debug, Clone, Copy, PartialEq, Eq ) ]
pub enum ArtifactLayout
{
File,
Directory,
}
#[ derive( Debug, Clone, Copy, PartialEq, Eq ) ]
pub enum ArtifactKind
{
Rule,
Command,
Agent,
Skill,
Plugin,
Hook,
}
impl ArtifactKind
{
#[ must_use ]
#[ inline ]
pub fn all() -> &'static [ Self ]
{
&[ Self::Rule, Self::Command, Self::Agent, Self::Skill, Self::Plugin, Self::Hook ]
}
#[ must_use ]
#[ inline ]
pub fn as_str( self ) -> &'static str
{
match self
{
Self::Rule => "rule",
Self::Command => "command",
Self::Agent => "agent",
Self::Skill => "skill",
Self::Plugin => "plugin",
Self::Hook => "hook",
}
}
#[ must_use ]
#[ inline ]
pub fn from_name( s : &str ) -> Option< Self >
{
match s
{
"rule" => Some( Self::Rule ),
"command" => Some( Self::Command ),
"agent" => Some( Self::Agent ),
"skill" => Some( Self::Skill ),
"plugin" => Some( Self::Plugin ),
"hook" => Some( Self::Hook ),
_ => None,
}
}
#[ must_use ]
#[ inline ]
pub fn source_subdir( self ) -> &'static str
{
match self
{
Self::Rule => "rules",
Self::Command => "commands",
Self::Agent => "agents",
Self::Skill => "skills",
Self::Plugin => "plugins",
Self::Hook => "hooks",
}
}
#[ must_use ]
#[ inline ]
pub fn target_subdir( self ) -> &'static str
{
match self
{
Self::Rule => "rules",
Self::Command => "commands",
Self::Agent => "agents",
Self::Skill => "skills",
Self::Plugin => "plugins",
Self::Hook => "hooks",
}
}
#[ must_use ]
#[ inline ]
pub fn layout( self ) -> ArtifactLayout
{
match self
{
Self::Rule | Self::Command | Self::Agent | Self::Hook => ArtifactLayout::File,
Self::Skill | Self::Plugin => ArtifactLayout::Directory,
}
}
#[ must_use ]
#[ inline ]
pub fn file_extension( self ) -> Option< &'static str >
{
match self
{
Self::Rule | Self::Command | Self::Agent => Some( "md" ),
Self::Hook => Some( "yaml" ),
Self::Skill | Self::Plugin => None,
}
}
}