Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 14, 2024
1 parent bff909f commit cd53a3e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
10 changes: 6 additions & 4 deletions cli/src/cli/generate/markdown.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::{Display, Formatter};
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use std::{env, fs};

use clap::Args;
use contracts::requires;
Expand Down Expand Up @@ -177,7 +177,7 @@ const COMMANDS_INDEX_TEMPLATE: &str = r#"
{% endfor %}
"#;

const COMMANDS_TEMPLATE: &str = r#"
const COMMAND_TEMPLATE: &str = r#"
### `{{ cmd.full_cmd | join(sep=" ") }}`
{% if cmd.before_long_help -%}
Expand Down Expand Up @@ -245,7 +245,9 @@ impl Display for UsageMdDirective {
UsageMdDirective::GlobalArgs => write!(f, "<!-- [USAGE] global_args -->"),
UsageMdDirective::GlobalFlags => write!(f, "<!-- [USAGE] global_flags -->"),
UsageMdDirective::CommandIndex => write!(f, "<!-- [USAGE] command_index -->"),
UsageMdDirective::Commands { .. } => write!(f, "<!-- [USAGE] commands -->"),
UsageMdDirective::Commands { inline_depth } => {
write!(f, "<!-- [USAGE] commands inline_depth={inline_depth} -->")
}
UsageMdDirective::Config => write!(f, "<!-- [USAGE] config -->"),
UsageMdDirective::EndToken => write!(f, "<!-- [USAGE] -->"),
UsageMdDirective::Plain(line) => write!(f, "{}", line),
Expand Down Expand Up @@ -373,7 +375,7 @@ impl UsageMdDirective {
for cmd in &commands {
let mut tctx = ctx.tera.clone();
tctx.insert("cmd", &cmd);
ctx.push(render_template(COMMANDS_TEMPLATE, &tctx)?);
ctx.push(render_template(COMMAND_TEMPLATE, &tctx)?);
}
ctx.push("<!-- [USAGE] -->".to_string());
}
Expand Down
2 changes: 1 addition & 1 deletion examples/MISE_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ foooooooo

<!-- [USAGE] -->
## Commands
<!-- [USAGE] commands -->
<!-- [USAGE] commands inline_depth=2 -->

### `activate`

Expand Down
7 changes: 3 additions & 4 deletions src/complete/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ mod tests {

#[test]
fn test_complete_bash() {
let spec: Spec = r#"
"#
.parse()
.unwrap();
let spec = r#"
"#;
let spec = Spec::parse(&Default::default(), spec).unwrap();
assert_snapshot!(complete_bash(&spec).trim(), @r###"
_() {
local raw
Expand Down
7 changes: 3 additions & 4 deletions src/complete/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ mod tests {

#[test]
fn test_complete_fish() {
let spec: Spec = r#"
"#
.parse()
.unwrap();
let spec = r#"
"#;
let spec = Spec::parse(&Default::default(), spec).unwrap();
assert_snapshot!(complete_fish(&spec).trim(), @r###"
set _usage_spec_ ''
complete -xc -a '(usage complete-word -s "$_usage_spec_" --ctoken=(commandline -t) -- (commandline -op))'
Expand Down
7 changes: 3 additions & 4 deletions src/complete/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ mod tests {

#[test]
fn test_complete_zsh() {
let spec: Spec = r#"
"#
.parse()
.unwrap();
let spec = r#"
"#;
let spec = Spec::parse(&Default::default(), spec).unwrap();
assert_snapshot!(complete_zsh(&spec).trim(), @r###"
#compdef
_() {
Expand Down
2 changes: 2 additions & 0 deletions src/parse/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ cmd "config" {
let cmd = clap::Command::new("test");
assert_display_snapshot!(Spec::from(&cmd), @r###"
name "test"
bin "test"
usage "Usage: test"
"###);
}
}

0 comments on commit cd53a3e

Please sign in to comment.