Skip to main content

SkillFrontmatter

Struct SkillFrontmatter 

Source
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: String

Skill 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

Source

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());
Source

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"));
Source

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"));
Source

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"]);
Source

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

Source§

fn clone(&self) -> SkillFrontmatter

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SkillFrontmatter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.