Commit 7fc0c07
committed
Show context specific help
In some cases we want to hide some parts of our help. For example if the user is on MacOS, information how to setup Windows or Linux system is not needed for him.
Add dynamicHelpProvider which is used to determine some context specific values.
Update common lib where we've added the following changes:
Add support for multilevel hierarchical commands. This way we can use commands like $ appbuilder appmanager upload android declared as "appmanager|upload|android".
Add support for passing multiple arguments to dynamic calls, by changing regular expressions.
Add DynamicHelpService which is used to check different conditions when printing our help.
Use _.isBoolean where possible. Add dynamicHelpProvider which should be implemented by each CLI.
Use lodash _.template as it uses microTemplate internally and pass the help through it. This way we can write javascript directly in our help.txt.
Replace of all entries in the help content (when executing), which match our dynamicCallRegex with this.$injector.dynamicCall($1).wait()
This way you can call dynamic methods, by just using:
\<%= #{platformService.validatePlatform} %\>
Add localVariables that allow easy call for default scenarios (isLinux, isMacOS, is Windows).
In order to use it, just call:
\<% if (isLinux) %\>
Practically you can add whatever javascript code you want in help.txt. Just wrap it inside <% %>
In case you want to call some method that returns string and you need the string in help.txt just write:
Some text... \<%= this.$injector.resolve("project").myMethod() %\> or even simpler:
Some text... \<%= #{project.myMethod} %\>
The code between <%= and %> will be executed (it's pure javascript, but you are able to use our $injector and $dynamicHelpService) and the returned string will be placed in the help file.
In case you want to limit some text only for specific case, just write:
\<% if (this.$dynamicHelpService.isPlatform("linux")) { %\>
In this version of the NativeScript CLI, you cannot build and deploy to iOS connected devices on Linux systems.
\<% } %\>
This way the code in if statement will be shown only in case command is run on linux.
You can simplify it by using localVariables added in common lib:
\<% if (isLinux) { %\>
In this version of the NativeScript CLI, you cannot build and deploy to iOS connected devices on Linux systems.
\<% } %\>
https://huboard.com/NativeScript/nativescript-cli#/issues/604819861 parent 918adf0 commit 7fc0c07
File tree
4 files changed
+27
-7
lines changed- lib
- resources
4 files changed
+27
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
- bootstrap.ts+2
- commands/help.ts+15-17
- declarations.d.ts+15
- definitions/bplist-parser.d.ts
- definitions/filesize.d.ts
- definitions/plist.d.ts
- definitions/progress-stream.d.ts
- definitions/yok.d.ts+1
- file-system.ts+1-1
- services/commands-service.ts+8-4
- services/dynamic-help-service.ts+28
- services/micro-templating-service.ts+24
- yok.ts+59-28
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
362 | | - | |
| 361 | + | |
| 362 | + | |
363 | 363 | | |
364 | 364 | | |
365 | | - | |
| 365 | + | |
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
501 | | - | |
502 | | - | |
| 501 | + | |
| 502 | + | |
503 | 503 | | |
504 | 504 | | |
505 | | - | |
| 505 | + | |
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
| |||
0 commit comments