mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:57:46 +00:00
LibCore: Support fine-grained failure behavior for ArgsParser
This commit is contained in:
parent
1dc31842cb
commit
250f8eccf3
4 changed files with 38 additions and 30 deletions
|
@ -22,6 +22,13 @@ public:
|
|||
No
|
||||
};
|
||||
|
||||
enum class FailureBehavior {
|
||||
PrintUsageAndExit,
|
||||
PrintUsage,
|
||||
Exit,
|
||||
Ignore,
|
||||
};
|
||||
|
||||
struct Option {
|
||||
bool requires_argument { true };
|
||||
const char* help_string { nullptr };
|
||||
|
@ -46,7 +53,7 @@ public:
|
|||
Function<bool(const char*)> accept_value;
|
||||
};
|
||||
|
||||
bool parse(int argc, char** argv, bool exit_on_failure = true);
|
||||
bool parse(int argc, char* const* argv, FailureBehavior failure_behavior = FailureBehavior::PrintUsageAndExit);
|
||||
// *Without* trailing newline!
|
||||
void set_general_help(const char* help_string) { m_general_help = help_string; };
|
||||
void print_usage(FILE*, const char* argv0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue