default method name to type name

This commit is contained in:
Aleksey Kladov 2018-08-31 15:10:37 +03:00
parent 05a9d42f54
commit 78d60a549d
4 changed files with 51 additions and 84 deletions

View file

@ -10,7 +10,7 @@ extern crate commandspec;
extern crate heck;
use clap::{App, Arg, SubCommand};
use heck::{CamelCase, ShoutySnakeCase};
use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
use std::{
collections::HashMap,
fs,
@ -91,6 +91,9 @@ fn render_template(template: &str) -> Result<String> {
tera.register_filter("camel", |arg, _| {
Ok(arg.as_str().unwrap().to_camel_case().into())
});
tera.register_filter("snake", |arg, _| {
Ok(arg.as_str().unwrap().to_snake_case().into())
});
tera.register_filter("SCREAM", |arg, _| {
Ok(arg.as_str().unwrap().to_shouty_snake_case().into())
});