Skip to content

Commit 965fddf

Browse files
Show HTML Help
## Use case: CLIs should be able to show HTML help when using ```<cli name> help <command name>``` When using ```<cli name> <command name> --help``` console help should be shown. When an error is raised in command, only console help is shown. ## Implementation * ```HelpCommand``` is modified to show console help when ```options.help``` is specified and html help when it is not. * Add ```HtmlHelpService``` which handles both console and html help by parsing markdown help files. * Each commands help is placed in a separate file. The files are markdown and they are used for both html and console help. * Html pages are generated from markdown on post-install. As post-install command could fail before generating html pages, when html help should be shown, we check if command name is valid and if the command exists, but its html help is missing, we generate all html pages. * Modify ```CommandsService``` to show console help by specifying options.help before calling ```HelpCommand``` * Modify ```DynamicHelpService``` and ```DynamicHelpProvider``` to accept isHtml option. When ```isHtml``` is specified, all localVariables will be set to true. This way html help will show full help, no matter of the conditions. * Add ```basic_page.html``` page and used three placeholders in it. The page is used to generate all html files, by replacing the placeholders with commands name, help content and path to css file. * Add ```styles.css``` file which contains styles used in html pages. * Add definitions for marked module. * Add ```appendFile``` method to ```FileSystem``` * Fix issue in yok, which was not requiring the first hierarchical command if it was not default one (if the hierarchical command doesn't have default command to execute) - this was leading to incorrect behavior when checking if command is valid. * Remove help.txt file
1 parent 5da63fa commit 965fddf

40 files changed

+967
-739
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ test-reports.xml
3030

3131
npm-debug.log
3232
node_modules
33+
docs/html

docs/helpers/basic-page.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>@MAN_PAGE_NAME@</title>
5+
<meta http-equiv="content-type" value="text/html;utf-8">
6+
<link rel="stylesheet" type="text/css" href="@RELATIVE_PATH_TO_STYLES_CSS@"/>
7+
</head>
8+
<body>
9+
@HTML_COMMAND_HELP@
10+
</body>
11+
</html>
12+

docs/helpers/styles.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
h1 {
2+
font-family:serif;
3+
font-size:50px;
4+
font-weight:bold;
5+
color: red;
6+
}
7+
8+
h2 {
9+
background:#eee;
10+
}
11+
h1, h2 {
12+
line-height:40px;
13+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
device android
2+
==========
3+
4+
Usage:
5+
`$ tns device android [--timeout <Milliseconds>]`
6+
Lists all recognized connected physical and running virtual devices with serial number and index.
7+
8+
If a connected Android device is not shown in the list, make sure that you have installed the required Android USB drivers on your system
9+
and that USB debugging is enabled on the device.
10+
11+
Options:
12+
* `--timeout` - Sets the time in milliseconds for the operation to search for connected devices before completing. The operation will continue to wait and listen for newly connected devices and will list them after the specified time expires. If not set, the default value is 4000.
13+
<% if(isHtml) { %>
14+
15+
#### Related Commands
16+
17+
Command | Description
18+
----------|----------
19+
[device ios](device-ios.html) | Lists all recognized connected iOS devices with serial number and index.
20+
[device list-applications](device-list-applications.html) | Lists the installed applications on all connected Android and iOS devices.
21+
[device log](device-log.html) | Opens the device log stream for a selected connected device.
22+
[device run](device-run.html) | Runs the selected application on a connected Android or iOS device.
23+
[device](device.html) | Lists all recognized connected devices with serial number and index, grouped by platform.
24+
<% } %>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
device ios
2+
==========
3+
4+
Usage:
5+
`$ tns device ios [--timeout <Milliseconds>]`
6+
7+
Lists all recognized connected iOS devices with serial number and index.
8+
9+
Options:
10+
* `--timeout` - Sets the time in milliseconds for the operation to search for connected devices before completing. The operation will continue to wait and listen for newly connected devices and will list them after the specified time expires. If not set, the default value is 4000.
11+
<% if(isHtml) { %>
12+
13+
#### Related Commands
14+
15+
Command | Description
16+
----------|----------
17+
[device android](device-android.html) | Lists all recognized connected physical and running virtual devices with serial number and index.
18+
[device list-applications](device-list-applications.html) | Lists the installed applications on all connected Android and iOS devices.
19+
[device log](device-log.html) | Opens the device log stream for a selected connected device.
20+
[device run](device-run.html) | Runs the selected application on a connected Android or iOS device.
21+
[device](device.html) | Lists all recognized connected devices with serial number and index, grouped by platform.
22+
<% } %>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
device list-applications
2+
==========
3+
4+
Usage:
5+
`$ tns device list-applications [--device <Device ID>]`
6+
7+
Lists the installed applications on all connected Android and iOS devices.
8+
9+
`<Device ID>` is the device index or identifier as listed by run `$ tns device`
10+
Options:
11+
* `--device` - If multiple devices are connected, sets the device for which you want to list all currently installed applications.
12+
<% if(isHtml) { %>
13+
14+
#### Related Commands
15+
16+
Command | Description
17+
----------|----------
18+
[device android](device-android.html) | Lists all recognized connected physical and running virtual devices with serial number and index.
19+
[device ios](device-ios.html) | Lists all recognized connected iOS devices with serial number and index.
20+
[device log](device-log.html) | Opens the device log stream for a selected connected device.
21+
[device run](device-run.html) | Runs the selected application on a connected Android or iOS device.
22+
[device](device.html) | Lists all recognized connected devices with serial number and index, grouped by platform.
23+
<% } %>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
device log
2+
==========
3+
4+
Usage:
5+
`$ tns device log --device <Device ID>`
6+
Opens the device log stream for a selected connected device.
7+
8+
`<Device ID>` is the device index or identifier as listed by `$ tns device`
9+
Options:
10+
* `--device` - If multiple devices are connected, sets the device for which you want to stream the log in the console.
11+
<% if(isHtml) { %>
12+
13+
#### Related Commands
14+
15+
Command | Description
16+
----------|----------
17+
[device android](device-android.html) | Lists all recognized connected physical and running virtual devices with serial number and index.
18+
[device ios](device-ios.html) | Lists all recognized connected iOS devices with serial number and index.
19+
[device list-applications](device-list-applications.html) | Lists the installed applications on all connected Android and iOS devices.
20+
[device run](device-run.html) | Runs the selected application on a connected Android or iOS device.
21+
[device](device.html) | Lists all recognized connected devices with serial number and index, grouped by platform.
22+
<% } %>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
device run
2+
==========
3+
4+
Usage:
5+
`$ tns device run <ApplicationId> [--device <Device ID>]`
6+
Runs the selected application on a connected Android or iOS device.
7+
You can run this command on one connected device at a time.
8+
9+
`<Application ID> is the application identifier as listed by `$ tns device list-applications`<Device ID>` is the device index or identifier as listed by run `$ tns device`
10+
Prerequisites:
11+
Before running your app on an iOS device, verify that your system and app meet the following requirements.
12+
* You are running the NativeScript CLI on an OS X system.
13+
* You have installed Xcode 5 or later.
14+
* You have built your app with the debug build configuration. Before running your app on an Android device, verify that your app meets the following requirement.
15+
* You have built your app with the debug build configuration.
16+
17+
Options:
18+
* `--device` - If multiple devices are connected, sets the device on which you want to run the app. You can run this command on one connected device at a time.
19+
<% if(isHtml) { %>
20+
21+
#### Related Commands
22+
23+
Command | Description
24+
----------|----------
25+
[device android](device-android.html) | Lists all recognized connected physical and running virtual devices with serial number and index.
26+
[device ios](device-ios.html) | Lists all recognized connected iOS devices with serial number and index.
27+
[device list-applications](device-list-applications.html) | Lists the installed applications on all connected Android and iOS devices.
28+
[device log](device-log.html) | Opens the device log stream for a selected connected device.
29+
[device](device.html) | Lists all recognized connected devices with serial number and index, grouped by platform.
30+
<% } %>

docs/man_pages/device/device.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
device
2+
==========
3+
4+
Usage:
5+
`$ tns device [<Command>]`
6+
Lists all recognized connected devices with serial number and index, grouped by platform. In this version of the NativeScript CLI,
7+
you can connect only iOS and Android devices.
8+
9+
`<Command>` is a related command that extends the device command. You can run the following related commands:
10+
* `android` - Lists all recognized connected Android physical and running Android virtual devices.
11+
* `ios` - Lists all recognized connected iOS devices.
12+
* `log` - Opens the device log stream for a selected connected device.
13+
* `list-applications` - Lists the installed applications on all connected Android `<% if(isWindows || isMacOS) { %>or iOS <%}%>`devices.
14+
* `run` - Runs the selected application on a connected Android `<% if(isMacOS) { %>or iOS <%}%>`device.
15+
<% if(isHtml) { %>
16+
17+
#### Related Commands
18+
19+
Command | Description
20+
----------|----------
21+
[device android](device-android.html) | Lists all recognized connected physical and running virtual devices with serial number and index.
22+
[device ios](device-ios.html) | Lists all recognized connected iOS devices with serial number and index.
23+
[device list-applications](device-list-applications.html) | Lists the installed applications on all connected Android and iOS devices.
24+
[device log](device-log.html) | Opens the device log stream for a selected connected device.
25+
[device run](device-run.html) | Runs the selected application on a connected Android or iOS device.
26+
<% } %>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
autocomplete
2+
==========
3+
4+
Turns on command line autocompletion for bash and zsh.
5+
6+
Usage:
7+
`$ tns autocomplete`
8+
9+
> NOTE: this will modify your .bash_profile, .bashrc and .zshrc files.
10+
<% if(isHtml) { %>
11+
12+
#### Related Commands
13+
14+
Command | Description
15+
----------|----------
16+
[feature-usage-tracking](feature-usage-tracking.html) | Configures anonymous usage statistics tracking for the NativeScript command-line interface.
17+
[help](help.html) | Lists the available commands or shows information about the selected command.
18+
<% } %>

0 commit comments

Comments
 (0)