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

Expand parser quantum functionality #26

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
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
32 changes: 30 additions & 2 deletions Core/NetArgumentParser/src/Subcommands/ParserQuantum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public virtual void ResetOptionsHandledState()
}
}

public void AddOptions(params ICommonOption[] options)
public virtual void AddOptions(params ICommonOption[] options)
{
ExtendedArgumentNullException.ThrowIfNull(options, nameof(options));
DefaultGroup.AddOptions(options);
Expand All @@ -80,7 +80,7 @@ public virtual bool RemoveOption(ICommonOption commonOption)
return _optionSet.RemoveOption(commonOption);
}

public void AddConverters(params IValueConverter[] converters)
public virtual void AddConverters(params IValueConverter[] converters)
{
ExtendedArgumentNullException.ThrowIfNull(converters, nameof(converters));
Array.ForEach(converters, _optionSet.AddConverter);
Expand All @@ -92,6 +92,21 @@ public virtual bool RemoveConverter(IValueConverter converter)
return _optionSet.RemoveConverter(converter);
}

public virtual void AddConverters(bool includeAllSubcommands, params IValueConverter[] converters)
{
ExtendedArgumentNullException.ThrowIfNull(converters, nameof(converters));

AddConverters(converters);

if (includeAllSubcommands)
{
foreach (Subcommand subcommand in Subcommands)
{
subcommand.AddConverters(includeAllSubcommands, converters);
}
}
}

public OptionGroup<ICommonOption> AddOptionGroup(string name, string? description = null)
{
ExtendedArgumentNullException.ThrowIfNull(name, nameof(name));
Expand Down Expand Up @@ -123,6 +138,19 @@ public IList<ICommonOption> GetAllOptions()
return options;
}

public IList<Subcommand> GetAllSubcommands()
{
var subcommands = new List<Subcommand>(Subcommands);

foreach (Subcommand subcommand in _subcommands)
{
IList<Subcommand> currSubcommands = subcommand.GetAllSubcommands();
subcommands.AddRange(currSubcommands);
}

return subcommands;
}

public Subcommand AddSubcommand(string name, string description)
{
ExtendedArgumentNullException.ThrowIfNull(name, nameof(name));
Expand Down
Loading