Simplify js api

This commit is contained in:
2021-04-03 22:27:41 +02:00
parent 907fdb4f10
commit 10af871d2b
9 changed files with 178 additions and 116 deletions
+22 -25
View File
@@ -5,42 +5,39 @@
*/
declare function echo(message: string): void
/**
* Prompt a user for text input
*
* @param text - The text to display for the prompt
* @param def - A default value
*/
declare function prompt(text: string, def?: string): string
declare interface prompt {
/**
* Prompt a user for text input
*
* @param text - The text to display for the prompt
* @param def - A default value
*/
declare function promptBoolean(text: string, def?: boolean): boolean
/**
* Prompt a user for text input
*
* @param text - The text to display for the prompt
* @param def - A default value
*/
string(text: string, def?: string): string
/**
* Prompt a user for text input
*
* @param text - The text to display for the prompt
* @param def - A default value
*/
boolean(text: string, def?: boolean): boolean
}
/**
* Renders a template
*
* @param name - The template name
* @param context - The template context
* @param output - The output path, if absent, default to the template name
*/
declare function render(name: string, context: any): string
/**
* Write a string to a file
*
* @param input - The content of the file
* @param output - The output path
*/
declare function write(input: string, output: string): void
declare function render(name: string, context: any, output?: string): string
/**
* Copy a file
*
* @param input - The input path
* @param output - The output path
* @param output - The output path, if absent, default to the input path
*/
declare function copy(input: string, output: string): void
declare function copy(input: string, output?: string): void
+2 -2
View File
@@ -1,7 +1,7 @@
echo("Example")
const name = prompt("Project name")
const name = prompt.string("Project name")
const ctx = {name: name}
write(render("README.md", ctx), "README.md")
render("README.md", ctx)