-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(help): add utility to create help screens
- Loading branch information
1 parent
2223f24
commit 35571b8
Showing
2 changed files
with
127 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* @adonisjs/ace | ||
* | ||
* (c) Harminder Virk <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { printHelp } from '../src/utils/help' | ||
import { BaseCommand } from '../src/BaseCommand' | ||
import { Kernel } from '../src/Kernel' | ||
|
||
class Greet extends BaseCommand { | ||
public static commandName = 'greet' | ||
public static description = 'Greet a user with their name' | ||
public static args = [ | ||
{ | ||
name: 'name', | ||
description: 'The name of the person you want to greet', | ||
required: true, | ||
}, | ||
{ | ||
name: 'age', | ||
required: false, | ||
}, | ||
] | ||
|
||
public static flags = [ | ||
{ | ||
name: 'env', | ||
description: 'The environment to use to specialize certain commands', | ||
type: 'boolean', | ||
}, | ||
{ | ||
name: 'entrypoint', | ||
description: 'The main HTML file that will be requested', | ||
type: 'string', | ||
}, | ||
{ | ||
name: 'fragment', | ||
alias: 'f', | ||
description: 'HTML fragments loaded on demand', | ||
type: 'array', | ||
}, | ||
] | ||
} | ||
|
||
class MakeController extends BaseCommand { | ||
public static commandName = 'make:controller' | ||
public static description = 'Create a HTTP controller' | ||
} | ||
|
||
class MakeModel extends BaseCommand { | ||
public static commandName = 'make:model' | ||
public static description = 'Create database model' | ||
} | ||
|
||
const kernel = new Kernel() | ||
kernel.flag('env', () => {}, { type: 'string' }) | ||
printHelp([Greet, MakeController, MakeModel], Object.keys(kernel.flags).map((flag) => { | ||
return kernel.flags[flag] | ||
})) |
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