using System; namespace Spectre.Console.Cli; /// /// An attribute representing a command argument. /// /// [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public sealed class CommandArgumentAttribute : Attribute { /// /// Gets the argument position. /// /// The argument position. public int Position { get; } /// /// Gets the value name of the argument. /// /// The value name of the argument. public string ValueName { get; } /// /// Gets a value indicating whether the argument is required. /// /// /// true if the argument is required; otherwise, false. /// public bool IsRequired { get; } /// /// Initializes a new instance of the class. /// /// The argument position. /// The argument template. public CommandArgumentAttribute(int position, string template) { if (template == null) { throw new ArgumentNullException(nameof(template)); } // Parse the option template. var result = TemplateParser.ParseArgumentTemplate(template); // Assign the result. Position = position; ValueName = result.Value; IsRequired = result.Required; } }