CLI: Allow single-character plugin option argument names
This commit is contained in:
@@ -90,11 +90,22 @@ namespace Il2CppInspector.CLI
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pluginOptionProperty = CreateAutoProperty(pluginOptionClass, option.Name, optionType);
|
var pluginOptionProperty = CreateAutoProperty(pluginOptionClass, option.Name, optionType);
|
||||||
var optCtorInfo = typeof(OptionAttribute).GetConstructor(new Type[] { typeof(string) });
|
|
||||||
|
ConstructorInfo optCtorInfo;
|
||||||
|
|
||||||
|
// Single character
|
||||||
|
if (option.Name.Length == 1)
|
||||||
|
optCtorInfo = typeof(OptionAttribute).GetConstructor(new Type[] { typeof(char) });
|
||||||
|
|
||||||
|
// Multiple characters
|
||||||
|
else
|
||||||
|
optCtorInfo = typeof(OptionAttribute).GetConstructor(new Type[] { typeof(string) });
|
||||||
|
|
||||||
var optHelpPropInfo = typeof(OptionAttribute).GetProperty("HelpText");
|
var optHelpPropInfo = typeof(OptionAttribute).GetProperty("HelpText");
|
||||||
var optDefaultInfo = typeof(OptionAttribute).GetProperty("Default");
|
var optDefaultInfo = typeof(OptionAttribute).GetProperty("Default");
|
||||||
var optRequiredInfo = typeof(OptionAttribute).GetProperty("Required");
|
var optRequiredInfo = typeof(OptionAttribute).GetProperty("Required");
|
||||||
var attBuilder = new CustomAttributeBuilder(optCtorInfo, new object[] { option.Name },
|
var attBuilder = new CustomAttributeBuilder(optCtorInfo,
|
||||||
|
new object[] { option.Name.Length == 1? (object) option.Name[0] : option.Name },
|
||||||
new PropertyInfo[] { optHelpPropInfo, optDefaultInfo, optRequiredInfo },
|
new PropertyInfo[] { optHelpPropInfo, optDefaultInfo, optRequiredInfo },
|
||||||
// Booleans are always optional
|
// Booleans are always optional
|
||||||
new object[] { option.Description, optionValue, option.Value is bool? false : option.Required });
|
new object[] { option.Description, optionValue, option.Value is bool? false : option.Required });
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ namespace Il2CppInspector.PluginAPI.V100
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the option as it will be supplied in an argument on the command-line
|
/// The name of the option as it will be supplied in an argument on the command-line
|
||||||
|
/// If you specify a single character, the single-dash syntax "-x" can be used instead of "--xxxxxx"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user