• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
usage() -> String15 pub fn usage() -> String {
16     "                         OpenHarmony device connector(HDC) ... \n".to_string()
17             + "---------------------------------global commands:---------------------------------- \n"
18             + " -h/help [verbose]                     - Print hdc help, 'verbose' for more other cmds \n"
19             + " -v/version                            - Print hdc version \n"
20             + " -t CONNECTKEY                         - Use device with given connect key \n"
21             + "---------------------------------component commands:------------------------------- \n"
22             + "session commands(on server): \n"
23             + " list targets [-v]                     - List all devices status, '-v' to display details \n"
24             + " start [-r]                            - Start server. '-r' to restart server \n"
25             + " kill [-r]                             - Kill server. '-r' to restart server \n"
26             + "service commands(on daemon): \n"
27             + " target mount                          - Set /system /vendor partition read-write \n"
28             + " target boot [-bootloader|-recovery]   - Reboot the device or boot into bootload / recovery. \n"
29             + " smode [-r]                            - Restart daemon with root permissions, '-r' to cancel \n"
30             + "                                         root permissions \n"
31             + " tmode usb                             - Reboot the device, listening on USB \n"
32             + " tmode port [PORT]                     - Reboot the device, listening on TCP port \n"
33             + "---------------------------------task commands:------------------------------------- \n"
34             + "file commands: \n"
35             + " file send [OPTION] LOCAL REMOTE       - Send file to device \n"
36             + " file recv [OPTION] REMOTE LOCAL       - Recv file from device \n"
37             + "                                         options are -a|-s|-z \n"
38             + "                                         -a: hold target file timestamp \n"
39             + "                                         -sync: just update newer file \n"
40             + "                                         -z: compress transfer \n"
41             + "                                         -m: mode sync \n"
42             + "forward commands: \n"
43             + " fport LOCALNODE REMOTENODE            - Forward local traffic to remote device \n"
44             + " rport REMOTENODE LOCALNODE            - Reserve remote traffic to local host \n"
45             + "                                         node config name format 'schema:content' \n"
46             + "                                         examples are below: \n"
47             + "                                         tcp:<port> \n"
48             + "                                         localfilesystem:<unix domain socket name> \n"
49             + "                                         localreserved:<unix domain socket name> \n"
50             + "                                         localabstract:<unix domain socket name> \n"
51             + "                                         dev:<device name> \n"
52             + "                                         jdwp:<pid> (remote only) \n"
53             + " fport ls                              - Display forward/reverse tasks \n"
54             + " fport rm TASK                         - Remove forward/reverse TASK \n"
55             + "app commands: \n"
56             + " install [-r|-s] PACKAGE               - Send package(s) to device and install them \n"
57             + "                                         src examples: single or multiple packages and \n"
58             + "                                         directories (.hap .hsp) \n"
59             + "                                         -r: replace existing application \n"
60             + "                                         -s: install shared bundle for multi-apps \n"
61             + " uninstall [-k] [-s] PACKAGE           - Remove application package from device \n"
62             + "                                         -k: keep the data and cache directories \n"
63             + "                                         -s: remove shared bundle \n"
64             + "debug commands: \n"
65             + " hilog [-h]                            - Show device log, '-h' to display details \n"
66             + " shell [COMMAND...]                    - Run shell command, \n"
67             + "                                         interactive shell if no command given \n"
68             + " bugreport [FILE]                      - Return all information from the device, \n"
69             + "                                         stored in file if FILE is specified \n"
70             + " jpid                                  - List pids of processes hosting a JDWP transport \n"
71             + "security commands: \n"
72             + " keygen FILE                           - Generate public/private key; \n"
73             + "                                         key stored in FILE and FILE.pub \n"
74 }
75 
verbose() -> String76 pub fn verbose() -> String {
77     let mut s = "                         OpenHarmony device connector(HDC) ... \n".to_string()
78             + "---------------------------------global commands:---------------------------------- \n"
79             + " -h/help [verbose]                     - Print hdc help, 'verbose' for more other cmds \n"
80             + " -v/version                            - Print hdc version \n"
81             + " -l[0-5]                               - Set runtime loglevel \n"
82             + " -t connectkey                         - Use device with given connect key \n"
83             + " checkserver                           - check client-server version \n"
84             + " checkdevice                           - check server-daemon version(only uart) \n"
85             + " \n"
86             + "---------------------------------component commands:------------------------------- \n"
87             + "session commands(on server): \n"
88             + " discover                              - Discover devices listening on TCP via LAN broadcast \n"
89             + " list targets [-v]                     - List all devices status, '-v' to display details \n"
90             + " tconn key                             - Connect device via key, TCP use IP:PORT \n"
91             + "                                         example:192.168.0.100:10178 \n"
92             + "                                         USB connect automatic. \n"
93             + "                                         TCP need to connect manually. \n";
94     if cfg!(HDC_SUPPORT_UART) {
95         s = s
96             + "                                         UART connect need connect manually. \n"
97             + "                                         Baud Rate can be specified with commas. \n"
98             + "                                         key format: PORTNAME[,BAUDRATE] \n"
99             + "                                         example: tconn COM5,921600 \n"
100             + "                                         Default Baud Rate is 921600. \n"
101     }
102     s
103             + " start [-r]                            - Start server. '-r' to restart server \n"
104             + " kill [-r]                             - Kill server. '-r' to restart server \n"
105             + " -s [ip:]port                          - Set hdc server listen config \n"
106             + " \n"
107             + "service commands(on daemon): \n"
108             + " target mount                          - Set /system /vendor partition read-write \n"
109             + " target boot [-bootloader|-recovery]   - Reboot the device or boot into bootloader / recovery. \n"
110             + " smode [-r]                            - Restart daemon with root permissions, '-r' to cancel \n"
111             + "                                         root permissions \n"
112             + " tmode usb                             - Reboot the device, listening on USB \n"
113             + " tmode port [PORT]                     - Reboot the device, listening on TCP port \n"
114             + " \n"
115             + "---------------------------------task commands:------------------------------------- \n"
116             + "file commands: \n"
117             + " file send [OPTION] LOCAL REMOTE       - Send file to device \n"
118             + " file recv [OPTION] REMOTE LOCAL       - Recv file from device \n"
119             + "                                         options are -a|-s|-z \n"
120             + "                                         -a: hold target file timestamp \n"
121             + "                                         -sync: just update newer file \n"
122             + "                                         -z: compress transfer \n"
123             + "                                         -m: mode sync \n"
124             + " \n"
125             + "forward commands: \n"
126             + " fport LOCALNODE REMOTENODE            - Forward local traffic to remote device \n"
127             + " rport REMOTENODE LOCALNODE            - Reserve remote traffic to local host \n"
128             + "                                         node config name format 'schema:content' \n"
129             + "                                         examples are below: \n"
130             + "                                         tcp:<port> \n"
131             + "                                         localfilesystem:<unix domain socket name> \n"
132             + "                                         localreserved:<unix domain socket name> \n"
133             + "                                         localabstract:<unix domain socket name> \n"
134             + "                                         dev:<device name> \n"
135             + "                                         jdwp:<pid> (remote only) \n"
136             + " fport ls                              - Display forward/reverse tasks \n"
137             + " fport rm TASK                         - Remove forward/reverse TASK \n"
138             + " \n"
139             + "app commands: \n"
140             + " install [-r|-s] PACKAGE               - Send package(s) to device and install them \n"
141             + "                                         src examples: single or multiple packages and \n"
142             + "                                         directories (.hap .hsp) \n"
143             + "                                         -r: replace existing application \n"
144             + "                                         -s: install shared bundle for multi-apps \n"
145             + " uninstall [-k] [-s] PACKAGE           - Remove application package from device \n"
146             + "                                         -k: keep the data and cache directories \n"
147             + "                                         -s: remove shared bundle \n"
148             + " \n"
149             + "debug commands: \n"
150             + " hilog [-h]                            - Show device log, '-h' to display details \n"
151             + " shell [COMMAND...]                    - Run shell command, \n"
152             + "                                         interactive shell if no command given \n"
153             + " bugreport [FILE]                      - Return all information from the device, \n"
154             + "                                         stored in file if FILE \n"
155             + "is specified \n"
156             + " jpid                                  - List pids of processes hosting a JDWP transport \n"
157             + " sideload [PATH]                       - Sideload the given full OTA package \n"
158             + " \n"
159             + "security commands: \n"
160             + " keygen FILE                           - Generate public/private key; \n"
161             + "                                         key stored in FILE and FILE.pub \n"
162             + " \n"
163             + "---------------------------------flash commands:------------------------------------ \n"
164             + "flash commands: \n"
165             + " update packagename                    - Update system by package \n"
166             + " flash [-f] PARTITION IMAGE            - Flash partition by image \n"
167             + " erase [-f] PARTITION                  - Erase partition \n"
168             + " format [-f] PARTITION                 - Format partition \n"
169 }
170