namespace Unosquare.Swan.Attributes { using System; /// /// Models an option specification. /// Based on CommandLine (Copyright 2005-2015 Giacomo Stelluti Scala and Contributors.). /// [AttributeUsage(AttributeTargets.Property)] public sealed class ArgumentOptionAttribute : Attribute { /// /// Initializes a new instance of the class. /// The default long name will be inferred from target property. /// public ArgumentOptionAttribute() : this(string.Empty, string.Empty) { } /// /// Initializes a new instance of the class. /// /// The long name of the option. public ArgumentOptionAttribute(string longName) : this(string.Empty, longName) { } /// /// Initializes a new instance of the class. /// /// The short name of the option. /// The long name of the option or null if not used. public ArgumentOptionAttribute(char shortName, string longName) : this(new string(shortName, 1), longName) { } /// /// Initializes a new instance of the class. /// /// The short name of the option.. public ArgumentOptionAttribute(char shortName) : this(new string(shortName, 1), string.Empty) { } private ArgumentOptionAttribute(string shortName, string longName) { ShortName = shortName ?? throw new ArgumentNullException(nameof(shortName)); LongName = longName ?? throw new ArgumentNullException(nameof(longName)); } /// /// Gets long name of this command line option. This name is usually a single English word. /// /// /// The long name. /// public string LongName { get; } /// /// Gets a short name of this command line option, made of one character. /// /// /// The short name. /// public string ShortName { get; } /// /// When applying attribute to target properties, /// it allows you to split an argument and consume its content as a sequence. /// public char Separator { get; set; } = '\0'; /// /// Gets or sets mapped property default value. /// /// /// The default value. /// public object DefaultValue { get; set; } /// /// Gets or sets a value indicating whether a command line option is required. /// /// /// true if required; otherwise, false. /// public bool Required { get; set; } /// /// Gets or sets a short description of this command line option. Usually a sentence summary. /// /// /// The help text. /// public string HelpText { get; set; } } }