VirtualBox

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

Last change on this file since 25275 was 25108, checked in by vboxsync, 14 years ago

Frontends/VBoxManage: the iSCSI backend doesn't support comments

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

© 2023 Oracle
ContactPrivacy policyTerms of Use