From b0e815a72bf4bfad6659a909a058cd86b7f9d56d Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdx@users.noreply.github.com> Date: Wed, 14 Feb 2024 06:48:26 -0600 Subject: [PATCH] added author field --- cli/src/cli/generate/markdown.rs | 4 ++-- examples/docs/MISE_INLINE.md | 13 ++++++++++++- examples/docs/cli-reference/completion.md | 9 +++++++++ examples/docs/cli-reference/usage.md | 4 +++- examples/mise.usage.kdl | 2 +- src/parse/spec.rs | 7 +++++++ 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/cli/src/cli/generate/markdown.rs b/cli/src/cli/generate/markdown.rs index fcc547a..489bc0f 100644 --- a/cli/src/cli/generate/markdown.rs +++ b/cli/src/cli/generate/markdown.rs @@ -26,8 +26,8 @@ pub struct Markdown { // spec_str: Option, /// A markdown file taken as input /// This file should have a comment like this: - /// - #[clap(required_unless_present = "out_dir", value_hint = clap::ValueHint::FilePath)] + /// + #[clap(required_unless_present = "out_dir", verbatim_doc_comment, value_hint = clap::ValueHint::FilePath)] inject: Option, /// Output markdown files to this directory diff --git a/examples/docs/MISE_INLINE.md b/examples/docs/MISE_INLINE.md index fcebf3b..e54565e 100644 --- a/examples/docs/MISE_INLINE.md +++ b/examples/docs/MISE_INLINE.md @@ -292,6 +292,15 @@ Shell type to generate completions for Shell type to generate completions for +##### Flag `--usage` + +Always use usage for completions. +Currently, usage is the default for fish and bash but not zsh since it has a few quirks +to work out first. + +This requires the `usage` CLI to be installed. +https://usage.jdx.dev + Examples: $ mise completion bash > /etc/bash_completion.d/mise @@ -1659,7 +1668,9 @@ Directly pipe stdin/stdout/stderr from plugin to user Sets --jobs=1 ## `mise usage` -Generate usage spec +Generate a usage CLI spec + +See https://usage.jdx.dev for more information ## `mise use` diff --git a/examples/docs/cli-reference/completion.md b/examples/docs/cli-reference/completion.md index 18e92ad..2a513be 100644 --- a/examples/docs/cli-reference/completion.md +++ b/examples/docs/cli-reference/completion.md @@ -10,6 +10,15 @@ Shell type to generate completions for Shell type to generate completions for +##### Flag `--usage` + +Always use usage for completions. +Currently, usage is the default for fish and bash but not zsh since it has a few quirks +to work out first. + +This requires the `usage` CLI to be installed. +https://usage.jdx.dev + Examples: $ mise completion bash > /etc/bash_completion.d/mise diff --git a/examples/docs/cli-reference/usage.md b/examples/docs/cli-reference/usage.md index 50c8007..0133ee5 100644 --- a/examples/docs/cli-reference/usage.md +++ b/examples/docs/cli-reference/usage.md @@ -1,3 +1,5 @@ # `mise usage` -Generate usage spec +Generate a usage CLI spec + +See https://usage.jdx.dev for more information diff --git a/examples/mise.usage.kdl b/examples/mise.usage.kdl index 97cd7f8..5e10228 100644 --- a/examples/mise.usage.kdl +++ b/examples/mise.usage.kdl @@ -1186,7 +1186,7 @@ case $cur in tool="${parts[0]}" prefix="${parts[1]}" - versions=$(mise ls-remote $tool $prefix | tail -r) + versions=$(mise ls-remote $tool $prefix | sed '1!G;h;$!d') for version in $versions; do echo "$tool@$version" diff --git a/src/parse/spec.rs b/src/parse/spec.rs index a84f3d7..4840ec3 100644 --- a/src/parse/spec.rs +++ b/src/parse/spec.rs @@ -24,6 +24,7 @@ pub struct Spec { pub usage: String, pub complete: IndexMap, + pub author: Option, pub about: Option, pub long_about: Option, } @@ -65,6 +66,7 @@ impl Spec { "name" => schema.name = node.arg(0)?.ensure_string()?, "bin" => schema.bin = node.arg(0)?.ensure_string()?, "version" => schema.version = Some(node.arg(0)?.ensure_string()?), + "author" => schema.author = Some(node.arg(0)?.ensure_string()?), "about" => schema.about = Some(node.arg(0)?.ensure_string()?), "long_about" => schema.long_about = Some(node.arg(0)?.ensure_string()?), "usage" => schema.usage = node.arg(0)?.ensure_string()?, @@ -171,6 +173,11 @@ impl Display for Spec { node.push(KdlEntry::new(version.clone())); nodes.push(node); } + if let Some(author) = &self.author { + let mut node = KdlNode::new("author"); + node.push(KdlEntry::new(author.clone())); + nodes.push(node); + } if let Some(about) = &self.about { let mut node = KdlNode::new("about"); node.push(KdlEntry::new(about.clone()));