Update the error text and "help" output for all commands which use a device or group ID

Signed-off-by: Aaron <admin@datahoarder.dev>

Aaron committed Jul 17, 2020 at 22:52 UTC ee45eb6d123c117874164cb0f8d361bd3c0e660a
1 file changed +55 -55
meshctrl.js
+55 -55
@@ -71,36 +71,36 @@ if (args['_'].length == 0) {
71 case 'listdevicegroups': { ok = true; break; }
72 case 'listdevices': { ok = true; break; }
73 case 'listusersofdevicegroup': {
74 - if (args.id == null) { console.log("Missing group id, use --id [groupid]"); }
74 + if (args.id == null) { console.log("Missing group id, use --id '[groupid]'"); }
75 else { ok = true; }
76 break;
77 }
78 case 'deviceinfo': {
79 - if (args.id == null) { console.log("Missing device id, use --id [deviceid]"); }
79 + if (args.id == null) { console.log("Missing device id, use --id '[deviceid]'"); }
80 else { ok = true; }
81 break;
82 }
83 case 'addusertodevicegroup': {
84 - if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id [groupid] or --group [groupname]"); }
84 + if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
85 else if (args.userid == null) { console.log("Add user to group missing useid, use --userid [userid]"); }
86 else { ok = true; }
87 break;
88 }
89 case 'removeuserfromdevicegroup': {
90 - if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id [groupid] or --group [groupname]"); }
90 + if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
91 else if (args.userid == null) { console.log("Remove user from group missing useid, use --userid [userid]"); }
92 else { ok = true; }
93 break;
94 }
95 case 'addusertodevice': {
96 - if (args.userid == null) { console.log("Add user to device missing useid, use --userid [userid]"); }
97 - else if (args.id == null) { console.log("Add user to device missing device id, use --id [deviceid]"); }
96 + if (args.userid == null) { console.log("Add user to device missing userid, use --userid [userid]"); }
97 + else if (args.id == null) { console.log("Add user to device missing device id, use --id '[deviceid]'"); }
98 else { ok = true; }
99 break;
100 }
101 case 'removeuserfromdevice': {
102 - if (args.userid == null) { console.log("Remove user from device missing useid, use --userid [userid]"); }
103 - else if (args.id == null) { console.log("Remove user from device missing device id, use --id [deviceid]"); }
102 + if (args.userid == null) { console.log("Remove user from device missing userid, use --userid [userid]"); }
103 + else if (args.id == null) { console.log("Remove user from device missing device id, use --id '[deviceid]'"); }
104 else { ok = true; }
105 break;
106 }
@@ -110,13 +110,13 @@ if (args['_'].length == 0) {
110 break;
111 }
112 case 'removedevicegroup': {
113 - if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id [groupid] or --group [groupname]"); }
113 + if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
114 else { ok = true; }
115 break;
116 }
117 case 'movetodevicegroup': {
118 - if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id [groupid] or --group [groupname]"); }
119 - else if (args.devid == null) { console.log("Device identifier missing, use --devid [deviceid]"); }
118 + if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
119 + else if (args.devid == null) { console.log("Device identifier missing, use --devid '[deviceid]'"); }
120 else { ok = true; }
121 break;
122 }
@@ -146,35 +146,35 @@ if (args['_'].length == 0) {
146 break;
147 }
148 case 'removeusergroup': {
149 - if (args.groupid == null) { console.log("Remove user group id missing, use --groupid [id]"); }
149 + if (args.groupid == null) { console.log("Remove user group id missing, use --groupid '[id]'"); }
150 else { ok = true; }
151 break;
152 }
153 case 'sendinviteemail': {
154 - if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id [groupid] or --group [groupname]"); }
154 + if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
155 else if (args.email == null) { console.log("Device email is missing, use --email [email]"); }
156 else { ok = true; }
157 break;
158 }
159 case 'generateinvitelink': {
160 - if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id [groupid] or --group [groupname]"); }
160 + if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
161 else if (args.hours == null) { console.log("Invitation validity period missing, use --hours [hours]"); }
162 else { ok = true; }
163 break;
164 }
165 case 'runcommand': {
166 - if (args.id == null) { console.log("Missing device id, use --id [deviceid]"); }
166 + if (args.id == null) { console.log("Missing device id, use --id '[deviceid]'"); }
167 else if (args.run == null) { console.log("Missing run, use --run \"command\""); }
168 else { ok = true; }
169 break;
170 }
171 case 'shell': {
172 - if (args.id == null) { console.log("Missing device id, use --id [deviceid]"); }
172 + if (args.id == null) { console.log("Missing device id, use --id '[deviceid]'"); }
173 else { ok = true; }
174 break;
175 }
176 case 'upload': {
177 - if (args.id == null) { console.log("Missing device id, use --id [deviceid]"); }
177 + if (args.id == null) { console.log("Missing device id, use --id '[deviceid]'"); }
178 else if (args.file == null) { console.log("Local file missing, use --file [file] specify the file to upload"); }
179 else if (args.target == null) { console.log("Remote target path missing, use --target [path] to specify the remote location"); }
180 else if (require('fs').existsSync(args.file) == false) { console.log("Local file does not exists, check --file"); }
@@ -182,7 +182,7 @@ if (args['_'].length == 0) {
182 break;
183 }
184 case 'download': {
185 - if (args.id == null) { console.log("Missing device id, use --id [deviceid]"); }
185 + if (args.id == null) { console.log("Missing device id, use --id '[deviceid]'"); }
186 else if (args.file == null) { console.log("Remote file missing, use --file [file] specify the remote file to download"); }
187 else if (args.target == null) { console.log("Target path missing, use --target [path] to specify the local download location"); }
188 else { ok = true; }
@@ -199,10 +199,10 @@ if (args['_'].length == 0) {
199 }
200 case 'sendinviteemail': {
201 console.log("Send invitation email with instructions on how to install the mesh agent for a specific device group. Example usage:\r\n");
202 - console.log(" MeshCtrl SendInviteEmail --id devicegroupid --message \"msg\" --email user@sample.com");
202 + console.log(" MeshCtrl SendInviteEmail --id 'groupid' --message \"msg\" --email user@sample.com");
203 console.log(" MeshCtrl SendInviteEmail --group \"My Computers\" --name \"Jack\" --email user@sample.com");
204 console.log("\r\nRequired arguments:\r\n");
205 - console.log(" --id [groupid] - Device group identifier (or --group).");
205 + console.log(" --id '[groupid]' - Device group identifier (or --group).");
206 console.log(" --group [groupname] - Device group name (or --id).");
207 console.log(" --email [email] - Email address.");
208 console.log("\r\nOptional arguments:\r\n");
@@ -212,10 +212,10 @@ if (args['_'].length == 0) {
212 }
213 case 'generateinvitelink': {
214 console.log("Generate a agent invitation URL for a given group. Example usage:\r\n");
215 - console.log(" MeshCtrl GenerateInviteLink --id devicegroupid --hours 24");
215 + console.log(" MeshCtrl GenerateInviteLink --id 'groupid' --hours 24");
216 console.log(" MeshCtrl GenerateInviteLink --group \"My Computers\" --hours 0");
217 console.log("\r\nRequired arguments:\r\n");
218 - console.log(" --id [groupid] - Device group identifier (or --group).");
218 + console.log(" --id '[groupid]' - Device group identifier (or --group).");
219 console.log(" --group [groupname] - Device group name (or --id).");
220 console.log(" --hours [hours] - Validity period in hours or 0 for infinit.");
221 break;
@@ -276,10 +276,10 @@ if (args['_'].length == 0) {
276 case 'listdevices': {
277 console.log("List devices, Example usages:\r\n");
278 console.log(" MeshCtrl ListDevices");
279 - console.log(" MeshCtrl ListDevices -id [groupid] --json");
279 + console.log(" MeshCtrl ListDevices -id '[groupid]' --json");
280 console.log("\r\nOptional arguments:\r\n");
281 - console.log(" --id [groupid] - Filter by group identifier (or --group).");
282 - console.log(" --group [groupname] - Filter by group name (or --id).");
281 + console.log(" --id '[groupid]' - Filter by group identifier (or --group).");
282 + console.log(" --group [groupname] - Filter by group name (or --id).");
283 console.log(" --count - Only return the device count.");
284 console.log(" --json - Show result as JSON.");
285 break;
@@ -288,7 +288,7 @@ if (args['_'].length == 0) {
288 console.log("List users that have permissions for a given device group, Example usage:\r\n");
289 console.log(" MeshCtrl ListUserOfDeviceGroup ");
290 console.log("\r\nRequired arguments:\r\n");
291 - console.log(" --id [groupid] - Device group identifier.");
291 + console.log(" --id '[groupid]' - Device group identifier.");
292 console.log("\r\nOptional arguments:\r\n");
293 console.log(" --json - Show result as JSON.");
294 break;
@@ -334,27 +334,27 @@ if (args['_'].length == 0) {
334 }
335 case 'removedevicegroup': {
336 console.log("Remove a device group, Example usages:\r\n");
337 - console.log(" MeshCtrl RemoveDeviceGroup --id groupid");
337 + console.log(" MeshCtrl RemoveDeviceGroup --id 'groupid'");
338 console.log("\r\nRequired arguments:\r\n");
339 - console.log(" --id [groupid] - Device group identifier (or --group).");
339 + console.log(" --id '[groupid]' - Device group identifier (or --group).");
340 console.log(" --group [groupname] - Device group name (or --id).");
341 break;
342 }
343 case 'movetodevicegroup': {
344 console.log("Move a device to a new device group, Example usages:\r\n");
345 - console.log(" MeshCtrl MoveToDeviceGroup --devid deviceid --id groupid");
345 + console.log(" MeshCtrl MoveToDeviceGroup --devid 'deviceid' --id 'groupid'");
346 console.log("\r\nRequired arguments:\r\n");
347 - console.log(" --id [groupid] - Device group identifier (or --group).");
347 + console.log(" --id '[groupid]' - Device group identifier (or --group).");
348 console.log(" --group [groupname] - Device group name (or --id).");
349 - console.log(" --devid [deviceid] - Device identifier.");
349 + console.log(" --devid '[deviceid]' - Device identifier.");
350 break;
351 }
352 case 'addusertodevicegroup': {
353 console.log("Add a user to a device group, Example usages:\r\n");
354 - console.log(" MeshCtrl AddUserToDeviceGroup --id groupid --userid userid --fullrights");
354 + console.log(" MeshCtrl AddUserToDeviceGroup --id 'groupid' --userid userid --fullrights");
355 console.log(" MeshCtrl AddUserToDeviceGroup --group groupname --userid userid --editgroup --manageusers");
356 console.log("\r\nRequired arguments:\r\n");
357 - console.log(" --id [groupid] - Device group identifier (or --group).");
357 + console.log(" --id '[groupid]' - Device group identifier (or --group).");
358 console.log(" --group [groupname] - Device group name (or --id).");
359 console.log(" --userid [userid] - The user identifier.");
360 console.log("\r\nOptional arguments:\r\n");
@@ -384,19 +384,19 @@ if (args['_'].length == 0) {
384 }
385 case 'removeuserfromdevicegroup': {
386 console.log("Remove a user from a device group, Example usages:\r\n");
387 - console.log(" MeshCtrl RemoveuserFromDeviceGroup --id groupid --userid userid");
387 + console.log(" MeshCtrl RemoveuserFromDeviceGroup --id 'groupid' --userid userid");
388 console.log("\r\nRequired arguments:\r\n");
389 - console.log(" --id [groupid] - Device group identifier (or --group).");
389 + console.log(" --id '[groupid]' - Device group identifier (or --group).");
390 console.log(" --group [groupname] - Device group name (or --id).");
391 console.log(" --userid [userid] - The user identifier.");
392 break;
393 }
394 case 'addusertodevice': {
395 console.log("Add a user to a device, Example usages:\r\n");
396 - console.log(" MeshCtrl AddUserToDevice --id deviceid --userid userid --fullrights");
397 - console.log(" MeshCtrl AddUserToDevice --id deviceid --userid userid --remotecontrol");
396 + console.log(" MeshCtrl AddUserToDevice --id 'deviceid' --userid userid --fullrights");
397 + console.log(" MeshCtrl AddUserToDevice --id 'deviceid' --userid userid --remotecontrol");
398 console.log("\r\nRequired arguments:\r\n");
399 - console.log(" --id [deviceid] - The device identifier.");
399 + console.log(" --id '[deviceid]' - The device identifier.");
400 console.log(" --userid [userid] - The user identifier.");
401 console.log("\r\nOptional arguments:\r\n");
402 console.log(" --fullrights - Allow full rights over this device.");
@@ -417,9 +417,9 @@ if (args['_'].length == 0) {
417 }
418 case 'removeuserfromdevice': {
419 console.log("Remove a user from a device, Example usages:\r\n");
420 - console.log(" MeshCtrl RemoveuserFromDeviceGroup --id deviceid --userid userid");
420 + console.log(" MeshCtrl RemoveuserFromDeviceGroup --id 'deviceid' --userid userid");
421 console.log("\r\nRequired arguments:\r\n");
422 - console.log(" --id [deviceid] - The device identifier.");
422 + console.log(" --id '[deviceid]' - The device identifier.");
423 console.log(" --userid [userid] - The user identifier.");
424 break;
425 }
@@ -432,10 +432,10 @@ if (args['_'].length == 0) {
432 }
433 case 'deviceinfo': {
434 console.log("Display information about a device, Example usages:\r\n");
435 - console.log(" MeshCtrl DeviceInfo --id deviceid");
436 - console.log(" MeshCtrl DeviceInfo --id deviceid --json");
435 + console.log(" MeshCtrl DeviceInfo --id 'deviceid'");
436 + console.log(" MeshCtrl DeviceInfo --id 'deviceid' --json");
437 console.log("\r\nRequired arguments:\r\n");
438 - console.log(" --id [deviceid] - The device identifier.");
438 + console.log(" --id '[deviceid]' - The device identifier.");
439 console.log("\r\nOptional arguments:\r\n");
440 console.log(" --raw - Output raw data in JSON format.");
441 console.log(" --json - Give results in JSON format.");
@@ -443,10 +443,10 @@ if (args['_'].length == 0) {
443 }
444 case 'runcommand': {
445 console.log("Run a shell command on a remote device, Example usages:\r\n");
446 - console.log(" MeshCtrl RunCommand --id deviceid --run \"command\"");
447 - console.log(" MeshCtrl RunCommand --id deviceid --run \"command\" --powershell");
446 + console.log(" MeshCtrl RunCommand --id 'deviceid' --run \"command\"");
447 + console.log(" MeshCtrl RunCommand --id 'deviceid' --run \"command\" --powershell");
448 console.log("\r\nRequired arguments:\r\n");
449 - console.log(" --id [deviceid] - The device identifier.");
449 + console.log(" --id '[deviceid]' - The device identifier.");
450 console.log(" --run \"[command]\" - Shell command to execute on the remote device.");
451 console.log("\r\nOptional arguments:\r\n");
452 console.log(" --powershell - Run in Windows PowerShell.");
@@ -454,30 +454,30 @@ if (args['_'].length == 0) {
454 }
455 case 'shell': {
456 console.log("Access a command shell on a remote device, Example usages:\r\n");
457 - console.log(" MeshCtrl Shell --id deviceid");
458 - console.log(" MeshCtrl Shell --id deviceid --powershell");
457 + console.log(" MeshCtrl Shell --id 'deviceid'");
458 + console.log(" MeshCtrl Shell --id 'deviceid' --powershell");
459 console.log("\r\nRequired arguments:\r\n");
460 - console.log(" --id [deviceid] - The device identifier.");
460 + console.log(" --id '[deviceid]' - The device identifier.");
461 console.log("\r\nOptional arguments:\r\n");
462 console.log(" --powershell - Run a Windows PowerShell.");
463 break;
464 }
465 case 'upload': {
466 console.log("Upload a local file to a remote device, Example usages:\r\n");
467 - console.log(" MeshCtrl Upload --id deviceid --file sample.txt --target c:\\");
468 - console.log(" MeshCtrl Upload --id deviceid --file sample.txt --target /tmp");
467 + console.log(" MeshCtrl Upload --id 'deviceid' --file sample.txt --target c:\\");
468 + console.log(" MeshCtrl Upload --id 'deviceid' --file sample.txt --target /tmp");
469 console.log("\r\nRequired arguments:\r\n");
470 - console.log(" --id [deviceid] - The device identifier.");
470 + console.log(" --id '[deviceid]' - The device identifier.");
471 console.log(" --file [localfile] - The local file to upload.");
472 console.log(" --target [remotepath] - The remote path to upload the file to.");
473 break;
474 }
475 case 'download': {
476 console.log("Download a file from a remote device, Example usages:\r\n");
477 - console.log(" MeshCtrl Download --id deviceid --file C:\\sample.txt --target c:\\temp");
478 - console.log(" MeshCtrl Download --id deviceid --file /tmp/sample.txt --target /tmp");
477 + console.log(" MeshCtrl Download --id 'deviceid' --file C:\\sample.txt --target c:\\temp");
478 + console.log(" MeshCtrl Download --id 'deviceid' --file /tmp/sample.txt --target /tmp");
479 console.log("\r\nRequired arguments:\r\n");
480 - console.log(" --id [deviceid] - The device identifier.");
480 + console.log(" --id '[deviceid]' - The device identifier.");
481 console.log(" --file [remotefile] - The remote file to download.");
482 console.log("\r\nOptional arguments:\r\n");
483 console.log(" --target [localpath] - The local path to download the file to.");