1 | ;
|
2 | /*
|
3 | * @adonisjs/ace
|
4 | *
|
5 | * (c) Harminder Virk <virk@adonisjs.com>
|
6 | *
|
7 | * For the full copyright and license information, please view the LICENSE
|
8 | * file that was distributed with this source code.
|
9 | */
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | exports.flags = void 0;
|
12 | /**
|
13 | * Pushes flag to the list of command flags with predefined
|
14 | * types.
|
15 | */
|
16 | function addFlag(type, options) {
|
17 | return function flag(target, propertyName) {
|
18 | const Command = target.constructor;
|
19 | Command.boot();
|
20 | Command.$addFlag(Object.assign({ type, propertyName }, options));
|
21 | };
|
22 | }
|
23 | exports.flags = {
|
24 | /**
|
25 | * Create a flag that excepts string values
|
26 | */
|
27 | string(options) {
|
28 | return addFlag('string', options || {});
|
29 | },
|
30 | /**
|
31 | * Create a flag that excepts numeric values
|
32 | */
|
33 | number(options) {
|
34 | return addFlag('number', options || {});
|
35 | },
|
36 | /**
|
37 | * Create a flag that excepts boolean values
|
38 | */
|
39 | boolean(options) {
|
40 | return addFlag('boolean', options || {});
|
41 | },
|
42 | /**
|
43 | * Create a flag that excepts array of string values
|
44 | */
|
45 | array(options) {
|
46 | return addFlag('array', options || {});
|
47 | },
|
48 | /**
|
49 | * Create a flag that excepts array of numeric values
|
50 | */
|
51 | numArray(options) {
|
52 | return addFlag('numArray', options || {});
|
53 | },
|
54 | };
|