|
5 | 5 | 1. Clone the repo by running 'git clone https://github.com/microsoft/botframework-cli.git' |
6 | 6 | 2. Inside the project folder run 'npm run build' |
7 | 7 | 3. Inside the packages folder(https://github.com/microsoft/botframework-cli/tree/master/packages) run 'npx oclif plugin <plugin-name>' |
| 8 | + 4. Follow the wizard and set the prompts: |
| 9 | + |
| 10 | + ? npm package: @microsoft/bf-<plugin-name> |
| 11 | + ? description: <Plugin brief description> |
| 12 | + ? author: Microsoft |
| 13 | + ? version: 1.0.0 |
| 14 | + ? license: MIT |
| 15 | + ? Who is the GitHub owner of repository (https://github.com/OWNER/repo): microsoft |
| 16 | + ? What is the GitHub name of repository (https://github.com/owner/REPO): botframework-cli |
| 17 | + ? Select a package manager: npm |
| 18 | + ? TypeScript: Y |
| 19 | + ? Use tslint (linter for TypeScript): Y |
| 20 | + ? Use mocha (testing framework): Y |
| 21 | + ? Add CI service config (Press <space> to select, <a> to toggle all, <i> to invert selection): select any |
| 22 | + |
8 | 23 | 4. Go to the folder created by the previous command and add @microsoft/bf-cli-command as a dependency in your package.json file |
| 24 | + |
| 25 | + "dependencies": { |
| 26 | + ..., |
| 27 | + "@microsoft/bf-cli-command": "1.0.0", |
| 28 | + ... |
| 29 | + } |
| 30 | + |
9 | 31 | 5. At the root level(https://github.com/microsoft/botframework-cli) run 'npm run build' to bootstrap the packages |
10 | 32 |
|
11 | 33 | ## Steps to create a new command |
12 | 34 | 1. Inside the plugin folder run 'npx oclif command <command-name>'. |
13 | 35 | a. To add a subcommand use a colon separated format as follows: |
14 | 36 | <command-name:subcommand-name> |
15 | | - 2. Replace the import 'import {Command, options} from '@oclif/command' line inside the newly created command with 'import {Command, options} from '@microsoft/bf-cli-command' |
16 | | - 3. Add the type to the options property like this: static options: options.Input<any> = {} |
| 37 | + 2. Replace the import 'import {Command, flags} from '@oclif/command' line inside the newly created command with '@microsoft/bf-cli-command' |
| 38 | + |
| 39 | + - import {Command, flags} from '@oclif/command' |
| 40 | + + import {Command, flags} from '@microsoft/bf-cli-command' |
| 41 | + |
| 42 | + 3. Add the typing to the flags property like this if needed: |
| 43 | + |
| 44 | + static flags: flags.Input<any> = { |
| 45 | + help: flags.help({description: 'Display help'}), |
| 46 | + } |
| 47 | + |
17 | 48 | 4. Implement the run method |
18 | 49 |
|
19 | 50 | ## General Guidelines |
@@ -55,14 +86,14 @@ Use the following verbs for standard commands |
55 | 86 |
|
56 | 87 | ### Other |
57 | 88 |
|
58 | | -* Commands and options are case InSenSiTive, specified in lower case. So *bf Cmd:SubCmd* is same as *bf cmd:subcmd*. |
| 89 | +* Commands and options are case SenSiTive, specified in lower case. *bf cmd:subcmd*. |
59 | 90 | * Multi word options are lowcase, nohyphen, multiwords. Multi word commands are forbidden. |
60 | | -* Always have attribute-value pairs on command line args (i.e. bf cmd --arg \<val\>, NOT bf cmd \<val\>). |
| 91 | +* Prefer flags to args |
61 | 92 | * Commands shall follow the *bf \[noun\]\[verb\]\[noun\]* form for example *bf qnamaker:create:kb*. |
62 | | -* Arguments with specific units: |
63 | | - * In general, DO NOT put units in argument names. ALWAYS put the expected units in the help text. Example: --durationinminutes should simply be --duration. This prevents the need to add more arguments later if more units are supported. |
| 93 | +* FLags with specific units: |
| 94 | + * In general, DO NOT put units in Flag names. ALWAYS put the expected units in the help text. Example: --durationinminutes should simply be --duration. This prevents the need to add more arguments later if more units are supported. |
64 | 95 | * Consider allowing a syntax that will let the user specify units. For example, even if the service requires a value in minutes, consider accepting 1h or 60m. It is fine to assume a default (i.e. 60 = 60 minutes). |
65 | | - * It is acceptable to use a unit in the argument name when it is used like an enum. For example, --startday is okay when it accepts MON, TUE, etc. --starthour is okay when it indicates an hour of the day. |
| 96 | + * It is acceptable to use a unit in the flag name when it is used like an enum. For example, --startday is okay when it accepts MON, TUE, etc. --starthour is okay when it indicates an hour of the day. |
66 | 97 | * Avoid having multiple arguments that simply represent different ways of getting the same thing. Instead, use a single descriptive name and overload it appropriately. For example, assume a command which can accept a parameter file through a URL or local path. |
67 | 98 |
|
68 | 99 | ### Porting Rules |
|
0 commit comments