You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Sets the name of the expected value, for the documentation, to valueName.
51
+
/// Sets the name of the expected value, for the documentation, to `value_name`.
52
+
///
53
+
/// Options without a value assigned have a boolean-like behavior: either the user specifies `–option` or they don't.
54
+
///
55
+
/// 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` and `output`, and a value name of file will appear as `-o, --output <file>`.
56
+
///
57
+
/// Call [`QCommandLineParser::value`](crate::QCommandLineParser::value) if you expect the option to be present only once, and [`QCommandLineParser::values`](crate::QCommandLineParser::values) if you expect that option to be present multiple times.
/// application argument --opt -t is interpreted as setting the options opt and t,
16
-
/// just like application --opt -t argument would do. This is the default parsing mode.
17
-
/// In order to specify that --opt and -t are positional arguments instead, the user can use --,
18
-
/// as in application argument -- --opt -t.
16
+
/// `application argument --opt -t` is interpreted as setting the options `opt` and `t`,
17
+
/// just like `application --opt -t argument` would do. This is the default parsing mode.
18
+
/// In order to specify that `--opt` and `-t` are positional arguments instead, the user can use `--`,
19
+
/// as in `application argument -- --opt -t`.
19
20
ParseAsOptions,
20
-
/// application argument --opt is interpreted as having two positional arguments, argument and --opt.
21
+
/// `application argument --opt` is interpreted as having two positional arguments, `argument` and `--opt`.
21
22
/// This mode is useful for executables that aim to launch other executables (e.g. wrappers, debugging tools, etc.)
22
23
/// or that support internal commands followed by options for the command. argument is the name of the command,
23
24
/// and all options occurring after it can be collected and parsed by another command line parser, possibly in another executable.
24
25
ParseAsPositionalArguments,
25
26
}
26
27
28
+
/// This enum describes the way the parser interprets command-line options that use a single dash followed by multiple letters, as `-abc`.
27
29
#[repr(i32)]
28
30
#[namespace = "rust::cxxqtlib1"]
29
31
#[derive(Debug)]
30
32
enumQCommandLineParserSingleDashWordOptionMode{
33
+
/// `-abc` is interpreted as `-a -b -c`, i.e. as three short options that have been compacted on the command-line, if none of the options take a value. If `a` takes a value, then it is interpreted as `-a bc`, i.e. the short option a followed by the value `bc`. This is typically used in tools that behave like compilers, in order to handle options such as `-DDEFINE=VALUE` or `-I/include/path`. This is the default parsing mode. New applications are recommended to use this mode.
31
34
ParseAsCompactedShortOptions,
35
+
/// `-abc` is interpreted as `--abc`, i.e. as the long option named `abc`. This is how Qt's own tools (uic, rcc...) have always been parsing arguments. This mode should be used for preserving compatibility in applications that were parsing arguments in such a way. There is an exception if the `a` option has the [`QCommandLineOption::ShortOptionStyle`] flag set, in which case it is still interpreted as `-a bc`.
32
36
ParseAsLongOptions,
33
37
}
34
38
@@ -44,18 +48,24 @@ mod ffi {
44
48
typeQStringList = cxx_qt_lib::QStringList;
45
49
46
50
/// Adds help options to the command-line parser.
51
+
///
52
+
/// The options specified for this command-line are described by `-h` or `--help`. On Windows, the alternative `-?` is also supported. The option `--help-all` extends that to include generic Qt options, not defined by this command, in the output.
53
+
///
54
+
/// These options are handled automatically by `QCommandLineParser`.
/// Returns a translated error text for the user. This should only be called when parse() returns false.
80
+
/// Returns a translated error text for the user. This should only be called when [`parse`](Self::parse) returns `false`.
71
81
#[rust_name = "error_text"]
72
82
fnerrorText(self:&QCommandLineParser) -> QString;
73
83
@@ -76,42 +86,75 @@ mod ffi {
76
86
fnhelpText(self:&QCommandLineParser) -> QString;
77
87
78
88
/// Returns a list of option names that were found.
89
+
///
90
+
/// This returns a list of all the recognized option names found by the parser, in the order in which they were found. For any long options that were in the form {–option=value}, the value part will have been dropped.
91
+
///
92
+
/// The names in this list do not include the preceding dash characters. Names may appear more than once in this list if they were encountered more than once by the parser.
93
+
///
94
+
/// Any entry in the list can be used with [`value`](Self::value) or with [`values`](Self::values) to get any relevant option values.
/// Most programs don't need to call this, a simple call to [`process`] is enough.
101
+
///
102
+
/// This function is more low-level, and only does the parsing. The application will have to take care of the error handling, using [`error_text`] if this function returns `false`. This can be useful for instance to show a graphical error message in graphical programs.
103
+
///
104
+
/// Calling this function instead of [`process`] can also be useful in order to ignore unknown options temporarily, because more option definitions will be provided later on (depending on one of the arguments), before calling [`process`].
105
+
///
106
+
/// Don't forget that arguments must start with the name of the executable (ignored, though).
107
+
///
108
+
/// Returns `false` in case of a parse error (unknown option or missing value); returns `true` otherwise.
/// In addition to parsing the options (like [`parse`](Self::parse)), this function also handles the builtin options and handles errors.
123
+
///
124
+
/// The builtin options are `--version` if [`add_version_option`](Self::add_version_option) was called and `--help` / `--help-all` if [`add_help_option`](Self::add_help_option) was called.
125
+
///
126
+
/// When invoking one of these options, or when an error happens (for instance an unknown option was passed), the current process will then stop, using the [exit](https://doc.qt.io/qt/qcoreapplication.html#exit)() function.
/// Displays the version information from QCoreApplication::applicationVersion(), and exits the application.
147
+
/// Displays the version information from [`QCoreApplication::application_version`](cxx_qt_lib::QCoreApplication::application_version), and exits the application.
148
+
///
149
+
/// This is automatically triggered by the `–version` option, but can also be used to display the version when not using [`process`](Self::process). The exit code is set to `EXIT_SUCCESS` (0).
111
150
#[rust_name = "show_version"]
112
151
fnshowVersion(self:&mutQCommandLineParser);
113
152
114
153
/// Returns a list of unknown option names.
154
+
///
155
+
/// This list will include both long and short name options that were not recognized. For any long options that were in the form {–option=value}, the value part will have been dropped and only the long name is added.
156
+
///
157
+
/// The names in this list do not include the preceding dash characters. Names may appear more than once in this list if they were encountered more than once by the parser.
/// QCoreApplication provides the command-line arguments as a simple list of strings.
150
-
/// QCommandLineParser provides the ability to define a set of options, parse the command-line arguments, and store which options have actually been used,aswellas option values.
192
+
/// The QCommandLineParser class provides a means for handling the command line options.
/// Returns the option value found for the given option name `option_name`, or an empty string if not found.
203
+
///
204
+
/// The name provided can be any long or short name of any option that was added with [`add_option`](Self::add_option). All the option names are treated as being equivalent. If the name is not recognized or that option was not present, an empty string is returned.
205
+
///
206
+
/// For options found by the parser, the last value found for that option is returned. If the option wasn't specified on the command line, the default value is returned.
207
+
///
208
+
/// If the option does not take a value, a warning is printed, and an empty string is returned.
/// Returns a list of option values found for the given option name `option_name`, or an empty list if not found.
214
+
///
215
+
/// The name provided can be any long or short name of any option that was added with [`add_option`](Self::add_option). All the options names are treated as being equivalent. If the name is not recognized or that option was not present, an empty list is returned.
216
+
///
217
+
/// For options found by the parser, the list will contain an entry for each time the option was encountered by the parser. If the option wasn't specified on the command line, the default values are returned.
218
+
///
219
+
/// An empty list is returned if the option does not take a value.
/// Checks whether the option name was passed to the application.
169
-
pubfnis_set(&self,name:&ffi::QString) -> bool{
224
+
/// Checks whether the option `name` was passed to the application.
225
+
///
226
+
/// Returns `true` if the option `name` was set, `false` otherwise.
227
+
///
228
+
/// The name provided can be any long or short name of any option that was added with [`add_option`](Self::add_option). All the options names are treated as being equivalent. If the name is not recognized or that option was not present, `false` is returned.
0 commit comments