Skip to content

Commit

Permalink
Added xml documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sakya committed Aug 17, 2022
1 parent 3d5b71c commit 05dfcfc
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CmdLineArgsParser/Attributes/DescriptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

namespace CmdLineArgsParser.Attributes
{
/// <summary>
/// Attribute to add description to a member
/// </summary>
public class DescriptionAttribute : System.Attribute, IDescription
{
/// <summary>
/// Create a new <see cref="DescriptionAttribute"/> with the given description
/// </summary>
/// <param name="description"></param>
public DescriptionAttribute(string description)
{
Description = description;
}

/// <summary>
/// The member description
/// </summary>
public string Description { get; set; }
}
}
20 changes: 20 additions & 0 deletions CmdLineArgsParser/Attributes/OptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@

namespace CmdLineArgsParser.Attributes
{
/// <summary>
/// Attribute to define an option
/// </summary>
public class OptionAttribute : System.Attribute, IDescription
{
/// <summary>
/// Create a new <see cref="OptionAttribute"/> with the given name
/// </summary>
/// <param name="name">The option name</param>
public OptionAttribute(string name)
{
Name = name;
}

/// <summary>
/// Create a new <see cref="OptionAttribute"/> with the given name ans short name
/// </summary>
/// <param name="name">The option name</param>
/// <param name="shortName">The option short name</param>
public OptionAttribute(string name, char shortName)
{
Name = name;
Expand Down Expand Up @@ -68,13 +80,21 @@ public OptionAttribute(string name, char shortName)
/// </summary>
public string MutuallyExclusive { get; set; }

/// <summary>
/// Get the option valid values
/// </summary>
/// <returns></returns>
public string[] GetValidValues()
{
if (!string.IsNullOrEmpty(ValidValues))
return ValidValues.Split(';');
return null;
}

/// <summary>
/// Get the option "only for verbs" values
/// </summary>
/// <returns></returns>
public string[] GetOnlyForVerbs()
{
if (!string.IsNullOrEmpty(OnlyForVerbs))
Expand Down
1 change: 1 addition & 0 deletions CmdLineArgsParser/CmdLineArgsParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>CmdLineArgsParser</PackageId>
<RootNamespace>CmdLineArgsParser</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="\" />
Expand Down
8 changes: 8 additions & 0 deletions CmdLineArgsParser/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@

namespace CmdLineArgsParser.Extensions
{
/// <summary>
/// String extensions
/// </summary>
public static class StringExtensions
{
/// <summary>
/// Turn the first character of a string to uppercase
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string Capitalize(this string str)
{
if (string.IsNullOrEmpty(str))
Expand Down
10 changes: 10 additions & 0 deletions CmdLineArgsParser/Helpers/EnumHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

namespace CmdLineArgsParser.Helpers
{
/// <summary>
/// Helper for enums
/// </summary>
public static class EnumHelper
{
/// <summary>
/// Get the enum value from a string, case insensitive
/// </summary>
/// <param name="type">The num type</param>
/// <param name="value">The value</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static object GetValue(Type type, string value)
{
if (!type.IsEnum)
Expand Down
3 changes: 3 additions & 0 deletions CmdLineArgsParser/IOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace CmdLineArgsParser
{
/// <summary>
/// Options
/// </summary>
public interface IOptions
{
}
Expand Down
6 changes: 6 additions & 0 deletions CmdLineArgsParser/Interfaces/IDescription.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
namespace CmdLineArgsParser.Interfaces
{
/// <summary>
/// Description
/// </summary>
public interface IDescription
{
/// <summary>
/// Description
/// </summary>
string Description { get; set; }
}
}
2 changes: 1 addition & 1 deletion CmdLineArgsParser/Parser.ShowUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace CmdLineArgsParser
public partial class Parser
{
/// <summary>
/// Writes options to the <see cref="Console"/>
/// Writes usage information tow the <see cref="Console"/>
/// </summary>
/// <param name="assemblyName">The assembly name to use for the usage line (defaults to the calling assembly name)</param>
/// <param name="columnsForName">The number of columns to reserve for option names (default: 0)</param>
Expand Down
7 changes: 7 additions & 0 deletions CmdLineArgsParser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ public bool HasValuesList
private OptionProperty _verbOption;
private object _verbValue;

/// <summary>
/// Create a new Parser with the given <see cref="ParserSettings"/>
/// </summary>
/// <param name="settings">The parser settings</param>
public Parser(ParserSettings settings = null)
{
if (settings == null)
settings = new ParserSettings();
Settings = settings;
}

/// <summary>
/// The parser <see cref="ParserSettings"/>
/// </summary>
public ParserSettings Settings { get; private set; }

#region private operations
Expand Down
15 changes: 15 additions & 0 deletions CmdLineArgsParser/ParserError.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
namespace CmdLineArgsParser
{
/// <summary>
/// A parser error
/// </summary>
public class ParserError
{
/// <summary>
/// Create a new <see cref="ParserError"/>
/// </summary>
/// <param name="optionName">The option name</param>
/// <param name="message">The error message</param>
public ParserError(string optionName, string message)
{
OptionName = optionName;
Message = message;
}

/// <summary>
/// The name of the option this error refers to
/// </summary>
public string OptionName { get; set; }

/// <summary>
/// The error message
/// </summary>
public string Message { get; set; }
}
}
3 changes: 3 additions & 0 deletions CmdLineArgsParser/ParserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace CmdLineArgsParser
/// </summary>
public class ParserSettings
{
/// <summary>
/// Create a new <see cref="ParserSettings"/>
/// </summary>
public ParserSettings()
{
DateTimeFormat = null;
Expand Down
2 changes: 1 addition & 1 deletion SolutionInfo.proj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<RespositoryType>git</RespositoryType>
<PackageTags>command line commandline argument option shell parser</PackageTags>
<Description>CmdLineArgsParser helps you parse command line arguments.</Description>
<Version>0.7.0.0</Version>
<Version>0.7.1.0</Version>
</PropertyGroup>
</Project>

0 comments on commit 05dfcfc

Please sign in to comment.