rewriting to oop and typescript

This commit is contained in:
2021-12-01 18:05:44 +01:00
parent 67d6029699
commit 1ebafbef49
123 changed files with 2129 additions and 5 deletions

66
src/help.ts Normal file
View File

@@ -0,0 +1,66 @@
import pad from 'pad'
import colors from 'colors'
export default class Help {
constructor() {
// this.logHelp()
}
// log help & returns status in string for tests
static makeHelp(): string {
const spc = 27
return `
Usage: make:[component]
${pad(' make controller [name]', spc)} create a new controller
${pad(' make middleware [name]', spc)} create a new middleware
${pad(' make model [name]', spc)} create a new model
${pad(' make route [name]', spc)} create a new route
${pad(' make test [name]', spc)} create a new test
${pad(' make view [name]', spc)} create a new view
`
}
static allHelp(): string {
const spc = 27
return `
Usage: nork <command> [options]
Options:
${pad(' -v, --version', spc)} output the version number
${pad(' -h, --help', spc)} output usage information
Commands:
${pad(' create [app-name]', spc)} create a new project
${pad(' create [app-name] -i', spc)} create a new project in current directory
${pad(' make controller [name]', spc)} create a new controller
${pad(' make interface [name]', spc)} create a new interface
${pad(' make middleware [name]', spc)} create a new middleware
${pad(' make model [name]', spc)} create a new model
${pad(' make route [name]', spc)} create a new route
${pad(' make service [name]', spc)} create a new service
${pad(' make test [name]', spc)} create a new test
${pad(' make view [name]', spc)} create a new view
${pad(' setup', spc)} set up an existing project for nork
Run ${colors.cyan('nork help <command>')} for detailed usage of given command.
`
}
static specificHelp(specific: string): string {
return `Usage: ${specific} [options]`
}
static logHelp = (specific: boolean | string = false): string => {
if (specific) {
// log specific help
if (specific == 'make') {
return this.makeHelp()
}
// else return specific help
return this.specificHelp(String(specific))
}
// if nothing return help all
return this.allHelp()
}
}