VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp@ 26163

Last change on this file since 26163 was 26089, checked in by vboxsync, 15 years ago

Branding: Moved the Product & Vendor strings to kBuild, so it could be used
there as well. Added a Copyright year define which points to the current year.
All this should be used on more places. For now the help strings of the
Frontends and most strings of the Mac OS X installer are updated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.5 KB
Line 
1/* $Id: VBoxManageHelp.cpp 26089 2010-01-28 17:08:19Z vboxsync $ */
2/** @file
3 * VBoxManage - help and other message output.
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <VBox/version.h>
27
28#include <iprt/ctype.h>
29#include <iprt/err.h>
30#include <iprt/getopt.h>
31#include <iprt/stream.h>
32
33#include "VBoxManage.h"
34
35
36
37void showLogo(void)
38{
39 static bool s_fShown; /* show only once */
40
41 if (!s_fShown)
42 {
43 RTPrintf(VBOX_PRODUCT" Command Line Management Interface Version "
44 VBOX_VERSION_STRING "\n"
45 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
46 "All rights reserved.\n"
47 "\n");
48 s_fShown = true;
49 }
50}
51
52void printUsage(USAGECATEGORY u64Cmd)
53{
54#ifdef RT_OS_LINUX
55 bool fLinux = true;
56#else
57 bool fLinux = false;
58#endif
59#ifdef RT_OS_WINDOWS
60 bool fWin = true;
61#else
62 bool fWin = false;
63#endif
64#ifdef RT_OS_SOLARIS
65 bool fSolaris = true;
66#else
67 bool fSolaris = false;
68#endif
69#ifdef RT_OS_FREEBSD
70 bool fFreeBSD = true;
71#else
72 bool fFreeBSD = false;
73#endif
74#ifdef RT_OS_DARWIN
75 bool fDarwin = true;
76#else
77 bool fDarwin = false;
78#endif
79#ifdef VBOX_WITH_VRDP
80 bool fVRDP = true;
81#else
82 bool fVRDP = false;
83#endif
84#ifdef VBOX_WITH_VBOXSDL
85 bool fVBoxSDL = true;
86#else
87 bool fVBoxSDL = false;
88#endif
89
90 if (u64Cmd == USAGE_DUMPOPTS)
91 {
92 fLinux = true;
93 fWin = true;
94 fSolaris = true;
95 fFreeBSD = true;
96 fDarwin = true;
97 fVRDP = true;
98 fVBoxSDL = true;
99 u64Cmd = USAGE_ALL;
100 }
101
102 RTPrintf("Usage:\n"
103 "\n");
104
105 if (u64Cmd == USAGE_ALL)
106 {
107 RTPrintf("VBoxManage [-v|--version] print version number and exit\n"
108 "VBoxManage [-q|--nologo] ... suppress the logo\n"
109 "\n");
110 }
111
112 if (u64Cmd & USAGE_LIST)
113 {
114 RTPrintf("VBoxManage list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|\n"
115#if defined(VBOX_WITH_NETFLT)
116 " bridgedifs|hostonlyifs|dhcpservers|hostinfo|\n"
117#else
118 " bridgedifs|dhcpservers|hostinfo|\n"
119#endif
120 " hostcpuids|hddbackends|hdds|dvds|floppies|\n"
121 " usbhost|usbfilters|systemproperties\n"
122 "\n");
123 }
124
125 if (u64Cmd & USAGE_SHOWVMINFO)
126 {
127 RTPrintf("VBoxManage showvminfo <uuid>|<name> [--details] [--statistics]\n"
128 " [--machinereadable]\n"
129 "\n");
130 }
131
132 if (u64Cmd & USAGE_REGISTERVM)
133 {
134 RTPrintf("VBoxManage registervm <filename>\n"
135 "\n");
136 }
137
138 if (u64Cmd & USAGE_UNREGISTERVM)
139 {
140 RTPrintf("VBoxManage unregistervm <uuid>|<name> [--delete]\n"
141 "\n");
142 }
143
144 if (u64Cmd & USAGE_CREATEVM)
145 {
146 RTPrintf("VBoxManage createvm --name <name>\n"
147 " [--ostype <ostype>]\n"
148 " [--register]\n"
149 " [--basefolder <path> | --settingsfile <path>]\n"
150 " [--uuid <uuid>]\n"
151 "\n");
152 }
153
154 if (u64Cmd & USAGE_MODIFYVM)
155 {
156 RTPrintf("VBoxManage modifyvm <uuid|name>\n"
157 " [--name <name>]\n"
158 " [--ostype <ostype>]\n"
159 " [--memory <memorysize in MB>]\n"
160 " [--vram <vramsize in MB>]\n"
161 " [--acpi on|off]\n"
162 " [--ioapic on|off]\n"
163 " [--pae on|off]\n"
164 " [--hwvirtex on|off]\n"
165 " [--nestedpaging on|off]\n"
166 " [--vtxvpid on|off]\n"
167 " [--cpuidset <leaf> <eax> <ebx> <ecx> <edx>]\n"
168 " [--cpuidremove <leaf>]\n"
169 " [--cpuidremoveall]\n"
170 " [--cpus <number>]\n"
171 " [--rtcuseutc]\n"
172 " [--monitorcount <number>]\n"
173 " [--accelerate3d <on|off>]\n"
174#ifdef VBOX_WITH_VIDEOHWACCEL
175 " [--accelerate2dvideo <on|off>]\n"
176#endif
177 " [--firmware bios|efi|efi32|efi64]\n"
178 " [--bioslogofadein on|off]\n"
179 " [--bioslogofadeout on|off]\n"
180 " [--bioslogodisplaytime <msec>]\n"
181 " [--bioslogoimagepath <imagepath>]\n"
182 " [--biosbootmenu disabled|menuonly|messageandmenu]\n"
183 " [--biossystemtimeoffset <msec>]\n"
184 " [--biospxedebug on|off]\n"
185 " [--boot<1-4> none|floppy|dvd|disk|net>]\n"
186#if defined(VBOX_WITH_NETFLT)
187 " [--nic<1-N> none|null|nat|bridged|intnet|hostonly]\n"
188#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
189 " [--nic<1-N> none|null|nat|bridged|intnet]\n"
190#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
191 " [--nictype<1-N> Am79C970A|Am79C973"
192#ifdef VBOX_WITH_E1000
193 "|\n 82540EM|82543GC|82545EM"
194#endif
195#ifdef VBOX_WITH_VIRTIO
196 "|\n virtio"
197#endif /* VBOX_WITH_VIRTIO */
198 "]\n"
199 " [--cableconnected<1-N> on|off]\n"
200 " [--nictrace<1-N> on|off]\n"
201 " [--nictracefile<1-N> <filename>]\n"
202 " [--nicspeed<1-N> <kbps>]\n"
203 " [--bridgeadapter<1-N> none|<devicename>]\n"
204#if defined(VBOX_WITH_NETFLT)
205 " [--hostonlyadapter<1-N> none|<devicename>]\n"
206#endif
207 " [--intnet<1-N> <network name>]\n"
208 " [--natnet<1-N> <network>|default]\n"
209 " [--macaddress<1-N> auto|<mac>]\n"
210 " [--uart<1-N> off|<I/O base> <IRQ>]\n"
211 " [--uartmode<1-N> disconnected|\n"
212 " server <pipe>|\n"
213 " client <pipe>|\n"
214 " file <file>|\n"
215 " <devicename>]\n"
216#ifdef VBOX_WITH_MEM_BALLOONING
217 " [--guestmemoryballoon <balloonsize in MB>]\n"
218#endif
219 " [--gueststatisticsinterval <seconds>]\n"
220 );
221 RTPrintf(" [--audio none|null");
222 if (fWin)
223 {
224#ifdef VBOX_WITH_WINMM
225 RTPrintf( "|winmm|dsound");
226#else
227 RTPrintf( "|dsound");
228#endif
229 }
230 if (fSolaris)
231 {
232 RTPrintf( "|solaudio"
233#ifdef VBOX_WITH_SOLARIS_OSS
234 "|oss"
235#endif
236 );
237 }
238 if (fLinux)
239 {
240 RTPrintf( "|oss"
241#ifdef VBOX_WITH_ALSA
242 "|alsa"
243#endif
244#ifdef VBOX_WITH_PULSE
245 "|pulse"
246#endif
247 );
248 }
249 if (fFreeBSD)
250 {
251 RTPrintf( "|oss"
252#ifdef VBOX_WITH_PULSE
253 "|pulse"
254#endif
255 );
256 }
257 if (fDarwin)
258 {
259 RTPrintf( "|coreaudio");
260 }
261 RTPrintf( "]\n");
262 RTPrintf(" [--audiocontroller ac97|sb16]\n"
263 " [--clipboard disabled|hosttoguest|guesttohost|\n"
264 " bidirectional]\n");
265 if (fVRDP)
266 {
267 RTPrintf(" [--vrdp on|off]\n"
268 " [--vrdpport default|<ports>]\n"
269 " [--vrdpaddress <host>]\n"
270 " [--vrdpauthtype null|external|guest]\n"
271 " [--vrdpmulticon on|off]\n"
272 " [--vrdpreusecon on|off]\n");
273 }
274 RTPrintf(" [--usb on|off]\n"
275 " [--usbehci on|off]\n"
276 " [--snapshotfolder default|<path>]\n"
277 " [--teleporter on|off]\n"
278 " [--teleporterport <port>]\n"
279 " [--teleporteraddress <address|empty>\n"
280 " [--teleporterpassword <password>]\n"
281 " [--hardwareuuid <uuid>]\n"
282 );
283 RTPrintf("\n");
284 }
285
286 if (u64Cmd & USAGE_IMPORTAPPLIANCE)
287 {
288 RTPrintf("VBoxManage import <ovf> [--dry-run|-n] [more options]\n"
289 " (run with -n to have options displayed\n"
290 " for a particular OVF)\n\n");
291 }
292
293 if (u64Cmd & USAGE_EXPORTAPPLIANCE)
294 {
295 RTPrintf("VBoxManage export <machines> --output|-o <ovf>\n"
296 " [--legacy09]\n"
297 " [--vsys <number of virtual system>]\n"
298 " [--product <product name>]\n"
299 " [--producturl <product url>]\n"
300 " [--vendor <vendor name>]\n"
301 " [--vendorurl <vendor url>]\n"
302 " [--version <version info>]\n"
303 " [--eula <license text>]\n"
304 " [--eulafile <filename>]\n"
305 "\n");
306 }
307
308 if (u64Cmd & USAGE_STARTVM)
309 {
310 RTPrintf("VBoxManage startvm <uuid>|<name>\n");
311 RTPrintf(" [--type gui");
312 if (fVBoxSDL)
313 RTPrintf( "|sdl");
314 if (fVRDP)
315 RTPrintf( "|vrdp");
316 RTPrintf( "|headless]\n");
317 RTPrintf("\n");
318 }
319
320 if (u64Cmd & USAGE_CONTROLVM)
321 {
322 RTPrintf("VBoxManage controlvm <uuid>|<name>\n"
323 " pause|resume|reset|poweroff|savestate|\n"
324 " acpipowerbutton|acpisleepbutton|\n"
325 " keyboardputscancode <hex> [<hex> ...]|\n"
326 " injectnmi|\n"
327 " setlinkstate<1-N> on|off |\n"
328#ifdef VBOX_DYNAMIC_NET_ATTACH
329#if defined(VBOX_WITH_NETFLT)
330 " nic<1-N> null|nat|bridged|intnet|hostonly\n"
331 " [<devicename>] |\n"
332#else /* !RT_OS_LINUX && !RT_OS_DARWIN */
333 " nic<1-N> null|nat|bridged|intnet\n"
334 " [<devicename>] |\n"
335#endif /* !RT_OS_LINUX && !RT_OS_DARWIN */
336 " nictrace<1-N> on|off\n"
337 " nictracefile<1-N> <filename>\n"
338#endif /* VBOX_DYNAMIC_NET_ATTACH */
339 " usbattach <uuid>|<address> |\n"
340 " usbdetach <uuid>|<address> |\n");
341 if (fVRDP)
342 {
343 RTPrintf(" vrdp on|off |\n");
344 RTPrintf(" vrdpport default|<ports> |\n");
345 }
346 RTPrintf(" setvideomodehint <xres> <yres> <bpp> [display] |\n"
347 " setcredentials <username> <password> <domain>\n"
348 " [--allowlocallogon <yes|no>] |\n"
349 " teleport --host <name> --port <port>\n"
350 " [--maxdowntime <msec>] [--password password]\n"
351 "\n");
352 }
353
354 if (u64Cmd & USAGE_DISCARDSTATE)
355 {
356 RTPrintf("VBoxManage discardstate <uuid>|<name>\n"
357 "\n");
358 }
359
360 if (u64Cmd & USAGE_ADOPTSTATE)
361 {
362 RTPrintf("VBoxManage adoptstate <uuid>|<name> <state_file>\n"
363 "\n");
364 }
365
366 if (u64Cmd & USAGE_SNAPSHOT)
367 {
368 RTPrintf("VBoxManage snapshot <uuid>|<name>\n"
369 " take <name> [--description <desc>] [--pause] |\n"
370 " delete <uuid>|<name> |\n"
371 " restore <uuid>|<name> |\n"
372 " restorecurrent |\n"
373 " edit <uuid>|<name>|--current\n"
374 " [--name <name>]\n"
375 " [--description <desc>] |\n"
376 " showvminfo <uuid>|<name>\n"
377 "\n");
378 }
379
380 if (u64Cmd & USAGE_OPENMEDIUM)
381 {
382 RTPrintf("VBoxManage openmedium disk|dvd|floppy <filename>\n"
383 " [--type normal|immutable|writethrough] (disk only)\n"
384 " [--uuid <uuid>]\n"
385 " [--parentuuid <uuid>] (disk only)\n"
386 "\n");
387 }
388
389 if (u64Cmd & USAGE_CLOSEMEDIUM)
390 {
391 RTPrintf("VBoxManage closemedium disk|dvd|floppy <uuid>|<filename>\n"
392 " [--delete]\n"
393 "\n");
394 }
395
396 if (u64Cmd & USAGE_STORAGEATTACH)
397 {
398 RTPrintf("VBoxManage storageattach <uuid|vmname>\n"
399 " --storagectl <name>\n"
400 " --port <number>\n"
401 " --device <number>\n"
402 " [--type <dvddrive|hdd|fdd>\n"
403 " --medium <none|emptydrive|uuid|filename|host:<drive>>]\n"
404 " [--passthrough <on|off>]\n"
405 " [--forceunmount]\n"
406 "\n");
407 }
408
409 if (u64Cmd & USAGE_STORAGECONTROLLER)
410 {
411 RTPrintf("VBoxManage storagectl <uuid|vmname>\n"
412 " --name <name>\n"
413 " [--add <ide/sata/scsi/floppy/sas>]\n"
414 " [--controller <LsiLogic/BusLogic/IntelAhci/PIIX3/PIIX4/ICH6/I82078/LsiLogicSas>]\n"
415 " [--sataideemulation<1-4> <1-30>]\n"
416 " [--sataportcount <1-30>]\n"
417 " [--remove]\n"
418 "\n");
419 }
420
421 if (u64Cmd & USAGE_SHOWHDINFO)
422 {
423 RTPrintf("VBoxManage showhdinfo <uuid>|<filename>\n"
424 "\n");
425 }
426
427 if (u64Cmd & USAGE_CREATEHD)
428 {
429 RTPrintf("VBoxManage createhd --filename <filename>\n"
430 " --size <megabytes>\n"
431 " [--format VDI|VMDK|VHD] (default: VDI)\n"
432 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
433 " [--type normal|writethrough] (default: normal)\n"
434 " [--comment <comment>]\n"
435 " [--remember]\n"
436 "\n");
437 }
438
439 if (u64Cmd & USAGE_MODIFYHD)
440 {
441 RTPrintf("VBoxManage modifyhd <uuid>|<filename>\n"
442 " [--type normal|writethrough|immutable]\n"
443 " [--autoreset on|off]\n"
444 " [--compact]\n"
445 "\n");
446 }
447
448 if (u64Cmd & USAGE_CLONEHD)
449 {
450 RTPrintf("VBoxManage clonehd <uuid>|<filename> <outputfile>\n"
451 " [--format VDI|VMDK|VHD|RAW|<other>]\n"
452 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
453 " [--type normal|writethrough|immutable]\n"
454 " [--remember] [--existing]\n"
455 "\n");
456 }
457
458 if (u64Cmd & USAGE_CONVERTFROMRAW)
459 {
460 RTPrintf("VBoxManage convertfromraw <filename> <outputfile>\n"
461 " [--format VDI|VMDK|VHD]\n"
462 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
463 "VBoxManage convertfromraw stdin <outputfile> <bytes>\n"
464 " [--format VDI|VMDK|VHD]\n"
465 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
466 "\n");
467 }
468
469 if (u64Cmd & USAGE_ADDISCSIDISK)
470 {
471 RTPrintf("VBoxManage addiscsidisk --server <name>|<ip>\n"
472 " --target <target>\n"
473 " [--port <port>]\n"
474 " [--lun <lun>]\n"
475 " [--encodedlun <lun>]\n"
476 " [--username <username>]\n"
477 " [--password <password>]\n"
478 " [--type normal|writethrough|immutable]\n"
479 " [--intnet]\n"
480 "\n");
481 }
482
483 if (u64Cmd & USAGE_GETEXTRADATA)
484 {
485 RTPrintf("VBoxManage getextradata global|<uuid>|<name>\n"
486 " <key>|enumerate\n"
487 "\n");
488 }
489
490 if (u64Cmd & USAGE_SETEXTRADATA)
491 {
492 RTPrintf("VBoxManage setextradata global|<uuid>|<name>\n"
493 " <key>\n"
494 " [<value>] (no value deletes key)\n"
495 "\n");
496 }
497
498 if (u64Cmd & USAGE_SETPROPERTY)
499 {
500 RTPrintf("VBoxManage setproperty hdfolder default|<folder> |\n"
501 " machinefolder default|<folder> |\n"
502 " vrdpauthlibrary default|<library> |\n"
503 " websrvauthlibrary default|null|<library> |\n"
504 " loghistorycount <value>\n"
505 "\n");
506 }
507
508 if (u64Cmd & USAGE_USBFILTER_ADD)
509 {
510 RTPrintf("VBoxManage usbfilter add <index,0-N>\n"
511 " --target <uuid>|<name>|global\n"
512 " --name <string>\n"
513 " --action ignore|hold (global filters only)\n"
514 " [--active yes|no] (yes)\n"
515 " [--vendorid <XXXX>] (null)\n"
516 " [--productid <XXXX>] (null)\n"
517 " [--revision <IIFF>] (null)\n"
518 " [--manufacturer <string>] (null)\n"
519 " [--product <string>] (null)\n"
520 " [--remote yes|no] (null, VM filters only)\n"
521 " [--serialnumber <string>] (null)\n"
522 " [--maskedinterfaces <XXXXXXXX>]\n"
523 "\n");
524 }
525
526 if (u64Cmd & USAGE_USBFILTER_MODIFY)
527 {
528 RTPrintf("VBoxManage usbfilter modify <index,0-N>\n"
529 " --target <uuid>|<name>|global\n"
530 " [--name <string>]\n"
531 " [--action ignore|hold] (global filters only)\n"
532 " [--active yes|no]\n"
533 " [--vendorid <XXXX>|\"\"]\n"
534 " [--productid <XXXX>|\"\"]\n"
535 " [--revision <IIFF>|\"\"]\n"
536 " [--manufacturer <string>|\"\"]\n"
537 " [--product <string>|\"\"]\n"
538 " [--remote yes|no] (null, VM filters only)\n"
539 " [--serialnumber <string>|\"\"]\n"
540 " [--maskedinterfaces <XXXXXXXX>]\n"
541 "\n");
542 }
543
544 if (u64Cmd & USAGE_USBFILTER_REMOVE)
545 {
546 RTPrintf("VBoxManage usbfilter remove <index,0-N>\n"
547 " --target <uuid>|<name>|global\n"
548 "\n");
549 }
550
551 if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
552 {
553 RTPrintf("VBoxManage sharedfolder add <vmname>|<uuid>\n"
554 " --name <name> --hostpath <hostpath>\n"
555 " [--transient] [--readonly]\n"
556 "\n");
557 }
558
559 if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
560 {
561 RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n"
562 " --name <name> [--transient]\n"
563 "\n");
564 }
565
566 if (u64Cmd & USAGE_VM_STATISTICS)
567 {
568 RTPrintf("VBoxManage vmstatistics <vmname>|<uuid> [--reset]\n"
569 " [--pattern <pattern>] [--descriptions]\n"
570 "\n");
571 }
572
573#ifdef VBOX_WITH_GUEST_PROPS
574 if (u64Cmd & USAGE_GUESTPROPERTY)
575 usageGuestProperty();
576#endif /* VBOX_WITH_GUEST_PROPS defined */
577
578 if (u64Cmd & USAGE_METRICS)
579 {
580 RTPrintf("VBoxManage metrics list [*|host|<vmname> [<metric_list>]]\n"
581 " (comma-separated)\n\n"
582 "VBoxManage metrics setup\n"
583 " [--period <seconds>]\n"
584 " [--samples <count>]\n"
585 " [--list]\n"
586 " [*|host|<vmname> [<metric_list>]]\n\n"
587 "VBoxManage metrics query [*|host|<vmname> [<metric_list>]]\n\n"
588 "VBoxManage metrics collect\n"
589 " [--period <seconds>]\n"
590 " [--samples <count>]\n"
591 " [--list]\n"
592 " [--detach]\n"
593 " [*|host|<vmname> [<metric_list>]]\n"
594 "\n");
595 }
596#if defined(VBOX_WITH_NETFLT)
597 if (u64Cmd & USAGE_HOSTONLYIFS)
598 {
599 RTPrintf("VBoxManage hostonlyif ipconfig <name>\n"
600 " [--dhcp |\n"
601 " --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |\n"
602 " --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]\n"
603# if defined(RT_OS_WINDOWS)
604 " create |\n"
605 " remove <name>\n"
606# endif
607 "\n");
608 }
609#endif
610
611 if (u64Cmd & USAGE_DHCPSERVER)
612 {
613 RTPrintf("VBoxManage dhcpserver add|modify --netname <network_name> |\n"
614#if defined(VBOX_WITH_NETFLT)
615 " --ifname <hostonly_if_name>\n"
616#endif
617 " [--ip <ip_address>\n"
618 " --netmask <network_mask>\n"
619 " --lowerip <lower_ip>\n"
620 " --upperip <upper_ip>]\n"
621 " [--enable | --disable]\n\n"
622 "VBoxManage dhcpserver remove --netname <network_name> |\n"
623#if defined(VBOX_WITH_NETFLT)
624 " --ifname <hostonly_if_name>\n"
625#endif
626 "\n");
627 }
628}
629
630/**
631 * Print a usage synopsis and the syntax error message.
632 */
633int errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
634{
635 va_list args;
636 showLogo(); // show logo even if suppressed
637#ifndef VBOX_ONLY_DOCS
638 if (g_fInternalMode)
639 printUsageInternal(u64Cmd);
640 else
641 printUsage(u64Cmd);
642#endif /* !VBOX_ONLY_DOCS */
643 va_start(args, pszFormat);
644 RTPrintf("\n"
645 "Syntax error: %N\n", pszFormat, &args);
646 va_end(args);
647 return 1;
648}
649
650/**
651 * errorSyntax for RTGetOpt users.
652 *
653 * @returns 1.
654 *
655 * @param fUsageCategory The usage category of the command.
656 * @param rc The RTGetOpt return code.
657 * @param pValueUnion The value union.
658 */
659int errorGetOpt(USAGECATEGORY fUsageCategory, int rc, union RTGETOPTUNION const *pValueUnion)
660{
661 showLogo(); // show logo even if suppressed
662#ifndef VBOX_ONLY_DOCS
663 if (g_fInternalMode)
664 printUsageInternal(fUsageCategory);
665 else
666 printUsage(fUsageCategory);
667#endif /* !VBOX_ONLY_DOCS */
668
669 if (rc == VINF_GETOPT_NOT_OPTION)
670 return RTPrintf("error: Invalid parameter '%s'\n", pValueUnion->psz);
671 if (rc > 0)
672 {
673 if (RT_C_IS_PRINT(rc))
674 return RTPrintf("error: Invalid option -%c\n", rc);
675 return RTPrintf("error: Invalid option case %i\n", rc);
676 }
677 if (rc == VERR_GETOPT_UNKNOWN_OPTION)
678 return RTPrintf("error: unknown option: %s\n", pValueUnion->psz);
679 if (pValueUnion->pDef)
680 return RTPrintf("error: %s: %Rrs\n", pValueUnion->pDef->pszLong, rc);
681 return RTPrintf("error: %Rrs\n", rc);
682}
683
684/**
685 * Print an error message without the syntax stuff.
686 */
687int errorArgument(const char *pszFormat, ...)
688{
689 va_list args;
690 va_start(args, pszFormat);
691 RTPrintf("error: %N\n", pszFormat, &args);
692 va_end(args);
693 return 1;
694}
695
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette