Add method to find specified operation
This commit is contained in:
parent
a1d6c3ba7b
commit
1c450d43a2
|
@ -527,6 +527,20 @@ Argument *Argument::wouldConflictWithArgument() const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the first operation argument specified by the user or nullptr if no operation has been specified.
|
||||
* \remarks Only direct sub arguments of this argument are considered.
|
||||
*/
|
||||
Argument *Argument::specifiedOperation() const
|
||||
{
|
||||
for (Argument *arg : m_subArgs) {
|
||||
if (arg->denotesOperation() && arg->isPresent()) {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets this argument and all sub arguments recursively.
|
||||
* \sa Argument::reset()
|
||||
|
@ -743,6 +757,21 @@ void ArgumentParser::resetArgs()
|
|||
m_actualArgc = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the first operation argument specified by the user or nullptr if no operation has been specified.
|
||||
* \remarks Only main arguments are considered. See Argument::specifiedOperation() to check sub arguments of a specific
|
||||
* argument.
|
||||
*/
|
||||
Argument *ArgumentParser::specifiedOperation() const
|
||||
{
|
||||
for (Argument *arg : m_mainArgs) {
|
||||
if (arg->denotesOperation() && arg->isPresent()) {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether at least one uncombinable main argument is present.
|
||||
*/
|
||||
|
|
|
@ -199,6 +199,7 @@ public:
|
|||
void setPreDefinedCompletionValues(const char *preDefinedCompletionValues);
|
||||
Argument *conflictsWithArgument() const;
|
||||
Argument *wouldConflictWithArgument() const;
|
||||
Argument *specifiedOperation() const;
|
||||
void reset();
|
||||
void resetRecursively();
|
||||
|
||||
|
@ -250,6 +251,7 @@ public:
|
|||
void setUnknownArgumentBehavior(UnknownArgumentBehavior behavior);
|
||||
Argument *defaultArgument() const;
|
||||
void setDefaultArgument(Argument *argument);
|
||||
Argument *specifiedOperation() const;
|
||||
void checkConstraints();
|
||||
void invokeCallbacks();
|
||||
bool isUncombinableMainArgPresent() const;
|
||||
|
|
Loading…
Reference in New Issue