QCommandLineOption¶
The
QCommandLineOption
class defines a possible command-line option. More…
New in version 5.2.
Synopsis¶
Functions¶
def
defaultValues
()def
description
()def
flags
()def
isHidden
()def
names
()def
setDefaultValue
(defaultValue)def
setDefaultValues
(defaultValues)def
setDescription
(description)def
setFlags
(aflags)def
setHidden
(hidden)def
setValueName
(name)def
swap
(other)def
valueName
()
Detailed Description¶
This class is used to describe an option on the command line. It allows different ways of defining the same option with multiple aliases possible. It is also used to describe how the option is used - it may be a flag (e.g.
-v
) or take a value (e.g.-o file
).Examples:
QCommandLineOption verboseOption("verbose", "Verbose mode. Prints out more information."); QCommandLineOption outputOption(QStringList() << "o" << "output", "Write generated data into <file>.", "file");See also
- class PySide2.QtCore.QCommandLineOption(other)¶
PySide2.QtCore.QCommandLineOption(name)
PySide2.QtCore.QCommandLineOption(name, description[, valueName=””[, defaultValue=””]])
PySide2.QtCore.QCommandLineOption(names)
PySide2.QtCore.QCommandLineOption(names, description[, valueName=””[, defaultValue=””]])
- Parameters:
name – str
valueName – str
description – str
names – list of strings
defaultValue – str
- PySide2.QtCore.QCommandLineOption.Flag¶
Constant
Description
QCommandLineOption.HiddenFromHelp
Hide this option in the user-visible help output. All options are visible by default. Setting this flag for a particular option makes it internal, i.e. not listed in the help output.
QCommandLineOption.ShortOptionStyle
The option will always be understood as a short option, regardless of what was set by
setSingleDashWordOptionMode
. This allows flags such as-DDEFINE=VALUE
or-I/include/path
to be interpreted as short flags even when the parser is inParseAsLongOptions
mode.See also
New in version 5.8.
- PySide2.QtCore.QCommandLineOption.defaultValues()¶
- Return type:
list of strings
Returns the default values set for this option.
See also
- PySide2.QtCore.QCommandLineOption.description()¶
- Return type:
str
Returns the description set for this option.
See also
- PySide2.QtCore.QCommandLineOption.flags()¶
- Return type:
Flags
Returns a set of flags that affect this command-line option.
See also
setFlags()
Flags
- PySide2.QtCore.QCommandLineOption.isHidden()¶
- Return type:
bool
Note
This function is deprecated.
Returns true if this option is omitted from the help output, false if the option is listed.
Use
flags()
&HiddenFromHelp
See also
setHidden()
HiddenFromHelp
- PySide2.QtCore.QCommandLineOption.names()¶
- Return type:
list of strings
Returns the names set for this option.
- PySide2.QtCore.QCommandLineOption.setDefaultValue(defaultValue)¶
- Parameters:
defaultValue – str
Sets the default value used for this option to
defaultValue
.The default value is used if the user of the application does not specify the option on the command line.
If
defaultValue
is empty, the option has no default values.See also
- PySide2.QtCore.QCommandLineOption.setDefaultValues(defaultValues)¶
- Parameters:
defaultValues – list of strings
Sets the list of default values used for this option to
defaultValues
.The default values are used if the user of the application does not specify the option on the command line.
See also
- PySide2.QtCore.QCommandLineOption.setDescription(description)¶
- Parameters:
description – str
Sets the description used for this option to
description
.It is customary to add a “.” at the end of the description.
The description is used by
showHelp()
.See also
- PySide2.QtCore.QCommandLineOption.setFlags(aflags)¶
- Parameters:
aflags –
Flags
Set the set of flags that affect this command-line option to
flags
.See also
flags()
Flags
- PySide2.QtCore.QCommandLineOption.setHidden(hidden)¶
- Parameters:
hidden – bool
Note
This function is deprecated.
Sets whether to hide this option in the user-visible help output.
All options are visible by default. Setting
hide
to true for a particular option makes it internal, i.e. not listed in the help output.Use
setFlags
(HiddenFromHelp
),HiddenFromHelp
See also
- PySide2.QtCore.QCommandLineOption.setValueName(name)¶
- Parameters:
name – str
Sets the name of the expected value, for the documentation, to
valueName
.Options without a value assigned have a boolean-like behavior: either the user specifies –option or they don’t.
Options with a value assigned need to set a name for the expected value, for the documentation of the option in the help output. An option with names
o
andoutput
, and a value name offile
will appear as-o, --output <file>
.Call
value()
if you expect the option to be present only once, andvalues()
if you expect that option to be present multiple times.See also
- PySide2.QtCore.QCommandLineOption.swap(other)¶
- Parameters:
Swaps option
other
with this option. This operation is very fast and never fails.
- PySide2.QtCore.QCommandLineOption.valueName()¶
- Return type:
str
Returns the name of the expected value.
If empty, the option doesn’t take a value.
See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.