Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command-line parser #123

Merged
merged 39 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d7d64e2
Add command-line parser
Xrayez Aug 7, 2021
c2fc422
Remove override keywords in `CommandLineParser`
Xrayez Aug 7, 2021
c7ff6ab
Fix shadowed variable when comparing option names
Xrayez Aug 7, 2021
6f8d80a
Formatting and style changes to `CommandLineParser`
Xrayez Aug 7, 2021
e10edfd
Fix typo in `get_occurrence_count` in `CommandLineParser`
Xrayez Aug 7, 2021
416d1e2
Documentation fixes for command-line parser related classes
Xrayez Aug 7, 2021
807c142
Rename `parse_args` to `parse` in `CommandLineParser`
Xrayez Aug 8, 2021
4fe0eb3
Add `CommandLineParser` test suite
Xrayez Aug 8, 2021
02d8645
Rename `get_error()` to `get_error_text()` in `CommandLineParser`
Xrayez Aug 8, 2021
7be1c72
Add test cases for `CommandLineParser`
Xrayez Aug 8, 2021
df0a2b3
Rename more method in `CommandLineParser`
Xrayez Aug 9, 2021
db474d3
Add short option and positional test cases in `CommandLineParser`
Xrayez Aug 9, 2021
d074e05
Remove dead code related to checkers in `CommandLineParser`
Xrayez Aug 9, 2021
9c02f16
Make help format parameter optional in `CommandLineParser.get_help_te…
Xrayez Aug 9, 2021
e0f102a
Move one-line implementation to declaration in `CommandLineParser`
Xrayez Aug 9, 2021
66e37de
Update docs for `CommandLineParser`
Xrayez Aug 9, 2021
7141f6e
Use `ERR_PARSE_ERROR` for `CommandLineParser`
Xrayez Aug 9, 2021
8b01b14
Merge `validate()` into `parse()` in `CommandLineParser`
Xrayez Aug 9, 2021
dcf414e
Add `new_option()` to `CommandLineParser`
Xrayez Aug 9, 2021
d6cb740
Change getter names to follow naming conventions in command line parser
Xrayez Aug 9, 2021
1a0fa2d
Use `index` over `idx` for CLI option arguments
Xrayez Aug 9, 2021
093b4d2
Declare `CommandLineParser` dependencies
Xrayez Aug 9, 2021
76a7e5c
Add more test cases for command line parser
Xrayez Aug 10, 2021
b66bbef
Rename `add_option()` to `append_option()`, `new_option()` to `add_op…
Xrayez Aug 10, 2021
05f4b44
Fix usage example of command-line parser
Xrayez Aug 10, 2021
1b77d73
Further improve docs for command-line parser
Xrayez Aug 11, 2021
b05da1d
Add prefix test cases for command-line parser
Xrayez Aug 11, 2021
514d73b
Fix `ParsedPrefix.is_exists()` name
Xrayez Aug 11, 2021
ff7ee37
Add important TODOs for Godot 4.0 regarding command-line parser
Xrayez Aug 11, 2021
1a41e9d
Add utility methods for `CommandLineOption`
Xrayez Aug 12, 2021
2eeadba
Validate disallowed default arguments in `CommandLineOption`
Xrayez Aug 12, 2021
8e4595c
Add test case for unrecognized options
Xrayez Aug 12, 2021
558dd3d
Move some variable closer to use in command-line parser
Xrayez Aug 12, 2021
37b7478
Mark `help` and `version` as special meta options
Xrayez Aug 12, 2021
f539979
Make sure meta option was parsed on the command-line
Xrayez Aug 12, 2021
a4859a6
Expose `meta` property in `CommandLineOption`
Xrayez Aug 12, 2021
20d3a30
Add positional options test case for command-line parser
Xrayez Aug 13, 2021
90ea98a
Simplify implementation of `CommandLineParser.add_option()` method
Xrayez Aug 13, 2021
9340536
Fix precedence of long prefix parsing in `CommandLineParser`
Xrayez Aug 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/command_line_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ struct CommandLineOption::ArgumentChecker {
struct CommandLineOption::FunctionChecker : public CommandLineOption::ArgumentChecker {
CheckFunction function;

bool check(const String &p_arg) const override {
Xrayez marked this conversation as resolved.
Show resolved Hide resolved
bool check(const String &p_arg) const {
return function(p_arg);
}
};

// struct CommandLineOption::CallableChecker : public CommandLineOption::ArgumentChecker {
// Callable callable;

// bool check(const String &p_arg) const override {
// bool check(const String &p_arg) const {
// Callable::CallError call_error;
// const Variant variant = p_arg;
// const Variant *args = { &variant };
Expand Down
2 changes: 1 addition & 1 deletion core/command_line_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CommandLineOption : public Reference {

CommandLineOption() = default;
explicit CommandLineOption(const PoolStringArray &p_names, int p_arg_count = 1);
~CommandLineOption() override;
~CommandLineOption();
};

class CommandLineHelpFormat : public Reference {
Expand Down