-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env -S usage bash | ||
#USAGE cmd "apply" { | ||
#USAGE arg "<file>" | ||
#USAGE } | ||
#USAGE cmd "select" {} | ||
|
||
function apply() { | ||
echo "Applying theme $1" | ||
} | ||
function select_theme() { | ||
echo "Selecting theme $1" | ||
} | ||
|
||
case "$1" in | ||
"apply") apply "$2" ;; | ||
"select") select_theme "$2" ;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::Spec; | ||
use once_cell::sync::Lazy; | ||
use tera::Tera; | ||
|
||
pub fn render_help(spec: &Spec) -> String { | ||
let mut ctx = tera::Context::new(); | ||
ctx.insert("spec", spec); | ||
TERA.render("spec_template.md.tera", &ctx) | ||
.unwrap() | ||
.trim() | ||
.to_string() | ||
+ "\n" | ||
} | ||
|
||
static TERA: Lazy<Tera> = Lazy::new(|| { | ||
let mut tera = Tera::default(); | ||
|
||
#[rustfmt::skip] | ||
tera.add_raw_templates([ | ||
("spec_template.md.tera", include_str!("templates/spec_template.tera")), | ||
]).unwrap(); | ||
|
||
// tera.register_filter( | ||
// "repeat", | ||
// move |value: &tera::Value, args: &HashMap<String, tera::Value>| { | ||
// let value = value.as_str().unwrap(); | ||
// let count = args.get("count").unwrap().as_u64().unwrap(); | ||
// Ok(value.repeat(count as usize).into()) | ||
// }, | ||
// ); | ||
|
||
tera | ||
}); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{%- if spec.about_long %}{{ spec.about_long }} | ||
|
||
{% elif spec.about %}{{ spec.about }} | ||
|
||
{% endif %} | ||
Usage: {{ spec.bin ~ " " ~ spec.cmd.usage | trim }} | ||
|
||
{%- if spec.cmd.subcommands %} | ||
|
||
Commands: | ||
{%- for name, cmd in spec.cmd.subcommands %} | ||
{{ cmd.usage | trim }}{% if cmd.aliases %} [aliases: {{ cmd.aliases | join(sep=", ") }}]{% endif %} | ||
{%- endfor %} | ||
help Print this message or the help of the given subcommand(s) | ||
{%- endif %} | ||
|
||
{%- if spec.cmd.args %} | ||
|
||
Arguments: | ||
{%- for arg in spec.cmd.args %} | ||
{{ arg.usage | trim }} | ||
{%- endfor %} | ||
{%- endif %} | ||
|
||
{%- if spec.cmd.flags %} | ||
|
||
Flags: | ||
{%- for flag in spec.cmd.flags %} | ||
{{ flag.usage | trim }}{% if flag.aliases %} [aliases: {{ flag.aliases | join(sep=", ") }}]{% endif %} | ||
{%- endfor %} | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod cli; | ||
pub mod markdown; |