VirtualBox

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

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

introduced VBoxManage modifyvm --rtcuseutc

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