Skip to content

Commit cd92ef7

Browse files
committed
Move ArgumentParser to C++ extension
Move ArgumentOption to C++ extension Add help message ANSI terminal coloring
1 parent 43c2950 commit cd92ef7

16 files changed

Lines changed: 898 additions & 448 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="ArgumentOption" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
3+
<brief_description>
4+
OpenVic commandline options for [ArgumentParser].
5+
</brief_description>
6+
<description>
7+
</description>
8+
<tutorials>
9+
</tutorials>
10+
<methods>
11+
<method name="get_help_string" qualifiers="const">
12+
<return type="String" />
13+
<param index="0" name="is_rich" type="bool" />
14+
<description>
15+
Returns the [ArgumentOption]'s help string formatted for printing.
16+
If [param is_rich] is [code]true[/code] then the string will include BBCode color formatting.
17+
</description>
18+
</method>
19+
<method name="has_alias" qualifiers="const">
20+
<return type="bool" />
21+
<param index="0" name="alias" type="String" />
22+
<description>
23+
Returns [code]true[/code] if [param alias] is in [member aliases].
24+
</description>
25+
</method>
26+
</methods>
27+
<members>
28+
<member name="aliases" type="PackedStringArray" setter="" getter="get_aliases" default="PackedStringArray()">
29+
The alternative names the option can be known by.
30+
</member>
31+
<member name="default_value" type="Variant" setter="" getter="get_default_value" default="null">
32+
The default value the option returns if not set.
33+
</member>
34+
<member name="description" type="String" setter="" getter="get_description" default="&quot;&quot;">
35+
The description for the option.
36+
</member>
37+
<member name="name" type="StringName" setter="" getter="get_name" default="&amp;&quot;&quot;">
38+
The name for the option.
39+
</member>
40+
<member name="option_arguments" type="String" setter="" getter="get_option_arguments" default="&quot;&quot;">
41+
The suffix arguments of the option following its name.
42+
If an argument contains "[lb]" and "[rb]", [method ArgumentOption.get_help_string]'s rich text formatting will give it a cyan BBCode color tag for the argument.
43+
If an argument contains "&lt;" and "&gt;", [method ArgumentOption.get_help_string]'s rich text formatting will give it a magenta BBCode color tag for the argument.
44+
</member>
45+
<member name="type" type="int" setter="" getter="get_type" enum="Variant.Type" default="0">
46+
The expected type of option.
47+
</member>
48+
</members>
49+
</class>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="ArgumentParser" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
3+
<brief_description>
4+
OpenVic commandline argument parser.
5+
</brief_description>
6+
<description>
7+
</description>
8+
<tutorials>
9+
</tutorials>
10+
<methods>
11+
<method name="get_help" qualifiers="const">
12+
<return type="String" />
13+
<param index="0" name="is_rich" type="bool" />
14+
<description>
15+
Returns the game application's help string formatted for printing.
16+
If [param is_rich] is [code]true[/code] then the string will include BBCode color formatting.
17+
See [method ArgumentOption.get_help_string].
18+
</description>
19+
</method>
20+
<method name="get_option_value" qualifiers="const">
21+
<return type="Variant" />
22+
<param index="0" name="arg_name" type="StringName" />
23+
<description>
24+
Returns the value set for [param arg_name] or [member ArgumentOption.default_value] if the option was not set.
25+
</description>
26+
</method>
27+
<method name="has_option" qualifiers="const">
28+
<return type="bool" />
29+
<param index="0" name="arg_name" type="StringName" />
30+
<param index="1" name="include_aliases" type="bool" default="false" />
31+
<description>
32+
Returns [code]true[/code] if [param arg_name] is a valid option.
33+
If [param include_aliases] is [code]true[/code] then also checks against [member ArgumentOption.aliases].
34+
</description>
35+
</method>
36+
<method name="is_option_set" qualifiers="const">
37+
<return type="bool" />
38+
<param index="0" name="arg_name" type="StringName" />
39+
<param index="1" name="include_aliases" type="bool" default="false" />
40+
<description>
41+
Returns [code]true[/code] if [param arg_name] was set either by [method parse_arguments] or [method set_option_value].
42+
Returns [code]false[/code] if [param arg_name] is not a valid option.
43+
If [param include_aliases] is [code]true[/code] then also searchs against [member ArgumentOption.aliases].
44+
</description>
45+
</method>
46+
<method name="parse_arguments">
47+
<return type="int" enum="Error" />
48+
<param index="0" name="args" type="PackedStringArray" />
49+
<param index="1" name="error_unknown" type="bool" default="true" />
50+
<description>
51+
Parses the arguments for the commandline into the [ArgumentParser]. This is run before game initialization for [method OS.get_cmdline_args] and [method OS.get_cmdline_user_args].
52+
Prints errors for unknown arguments when [param error_unknown] is true.
53+
</description>
54+
</method>
55+
<method name="set_option_value">
56+
<return type="void" />
57+
<param index="0" name="arg_name" type="StringName" />
58+
<param index="1" name="value" type="Variant" />
59+
<description>
60+
Sets the option's argument of [param arg_name] to value of [param value].
61+
</description>
62+
</method>
63+
</methods>
64+
</class>

0 commit comments

Comments
 (0)