Add snake case properties

This commit is contained in:
zhangrubing 2020-08-20 10:05:23 +08:00
parent 82c2122bcf
commit e4761d8f50
3 changed files with 6 additions and 2 deletions

View File

@ -11,7 +11,7 @@ export default interface IGenerationOptions {
noConfigs: boolean;
convertCaseFile: "pascal" | "param" | "camel" | "none";
convertCaseEntity: "pascal" | "camel" | "none";
convertCaseProperty: "pascal" | "camel" | "none";
convertCaseProperty: "pascal" | "camel" | "snake" | "none";
convertEol: "LF" | "CRLF";
propertyVisibility: "public" | "protected" | "private" | "none";
lazy: boolean;

View File

@ -212,6 +212,9 @@ function createHandlebarsHelpers(generationOptions: IGenerationOptions): void {
case "none":
retStr = str;
break;
case "snake":
retStr = changeCase.snakeCase(str);
break;
default:
throw new Error("Unknown case style");
}

View File

@ -11,6 +11,7 @@ import IGenerationOptions, {
import fs = require("fs-extra");
import inquirer = require("inquirer");
import path = require("path");
import { string } from "yargs";
// eslint-disable-next-line @typescript-eslint/no-floating-promises
CliLogic();
@ -211,7 +212,7 @@ function checkYargsParameters(options: options): options {
},
cp: {
alias: "case-property",
choices: ["pascal", "camel", "none"],
choices: ["pascal", "camel", "snake", "none"],
default: options.generationOptions.convertCaseProperty,
describe: "Convert property names to specified case",
},