pub struct SkillFrontmatter {
pub name: String,
pub version: Option<String>,
pub description: Option<String>,
pub requires_bins: Vec<String>,
pub extra: HashMap<String, Value>,
}Expand description
Optional YAML frontmatter to prepend to a skill file.
When provided to render_skill_file_with_frontmatter, the frontmatter
is serialized as a YAML block between --- delimiters and prepended
to the Markdown content.
§Example output
---
name: deploy
version: 1.0.0
description: Deploy the application
requires_bins:
- mytool
extra:
min_role: "ops"
---
# Skill: deploy
...§Examples
use argot_cmd::render::SkillFrontmatter;
let fm = SkillFrontmatter::new("mytool-deploy")
.version("1.0.0")
.description("Deploy the application")
.requires_bin("mytool");
assert_eq!(fm.name, "mytool-deploy");
assert_eq!(fm.version.as_deref(), Some("1.0.0"));
assert_eq!(fm.requires_bins, vec!["mytool"]);Fields§
§name: StringSkill identifier (e.g. "mytool-deploy"). Required.
version: Option<String>Semantic version string (e.g. "1.0.0"). Optional.
description: Option<String>Human-readable description. Optional. Falls back to the command’s
summary field when None is passed to a render function.
requires_bins: Vec<String>Binaries required to use this skill (e.g. ["mytool"]). Optional.
extra: HashMap<String, Value>Arbitrary extra key/value metadata included under an extra: key.
Values are serde_json::Value.
Implementations§
Source§impl SkillFrontmatter
impl SkillFrontmatter
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new SkillFrontmatter with only a required name.
All other fields default to None / empty.
§Examples
use argot_cmd::render::SkillFrontmatter;
let fm = SkillFrontmatter::new("my-skill");
assert_eq!(fm.name, "my-skill");
assert!(fm.version.is_none());Sourcepub fn version(self, v: impl Into<String>) -> Self
pub fn version(self, v: impl Into<String>) -> Self
Set the semantic version string (builder style).
§Examples
use argot_cmd::render::SkillFrontmatter;
let fm = SkillFrontmatter::new("my-skill").version("2.0.0");
assert_eq!(fm.version.as_deref(), Some("2.0.0"));Sourcepub fn description(self, d: impl Into<String>) -> Self
pub fn description(self, d: impl Into<String>) -> Self
Set the human-readable description (builder style).
When not set, render_skill_file_with_frontmatter falls back to
the command’s summary field.
§Examples
use argot_cmd::render::SkillFrontmatter;
let fm = SkillFrontmatter::new("my-skill").description("Does things");
assert_eq!(fm.description.as_deref(), Some("Does things"));Sourcepub fn requires_bin(self, bin: impl Into<String>) -> Self
pub fn requires_bin(self, bin: impl Into<String>) -> Self
Append a required binary to requires_bins (builder style).
May be called multiple times to add several binaries.
§Examples
use argot_cmd::render::SkillFrontmatter;
let fm = SkillFrontmatter::new("my-skill")
.requires_bin("mytool")
.requires_bin("jq");
assert_eq!(fm.requires_bins, vec!["mytool", "jq"]);Sourcepub fn extra(self, key: impl Into<String>, value: Value) -> Self
pub fn extra(self, key: impl Into<String>, value: Value) -> Self
Insert an arbitrary key/value pair into extra (builder style).
Values are serde_json::Value so they can represent any JSON-compatible
type. They are serialized as compact inline JSON in the frontmatter output.
§Examples
use argot_cmd::render::SkillFrontmatter;
let fm = SkillFrontmatter::new("my-skill")
.extra("min_role", serde_json::json!("ops"));
assert_eq!(fm.extra["min_role"], serde_json::json!("ops"));Trait Implementations§
Source§impl Clone for SkillFrontmatter
impl Clone for SkillFrontmatter
Source§fn clone(&self) -> SkillFrontmatter
fn clone(&self) -> SkillFrontmatter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more