// Copyright Keysight Technologies 2012-2019
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at http://mozilla.org/MPL/2.0/.
using System;
namespace OpenTap.Cli
{
///
/// When used on a property inside a , this attribute indicates a command line arugment or switch.
///
///
/// The property type can be: bool, string, or string[]. If it's bool the argument will not take an argument, but will instead set the property to true.
/// If it's a string the value of the property will be set to the first occuring value set in the CLI arguments.
/// If it's a string[] all values set in the CLI arguments will be concatenated into an array.
///
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
public class CommandLineArgumentAttribute : Attribute
{
///
/// Indicates the long name of the command line argument.
///
public string Name { get; private set; }
///
/// Indicates the short name of the argument. This should be 1 character.
///
public string ShortName { get; set; }
///
/// Human readable description of the argument.
///
public string Description { get; set; }
///
/// Indicates whether this will be shown when writing CLI usage information.
///
[Obsolete("Please use the 'Browsable' attribute.")]
public bool Visible { get; set; } = true;
///
/// Primary constructor.
///
/// Long name of the argument.
public CommandLineArgumentAttribute(string name)
{
this.Name = name;
ShortName = null;
Description = null;
}
}
///
/// Used on properties of a to define an unnamed arguments on the CLI. These can be ordered to handle cases where some values are required and others can occur multiple times.
/// The property type will indicate how many will be consumed. The type can be either string or string[]. In case of string[] all the remaining arguments will be assigned to this property.
///
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
public class UnnamedCommandLineArgument : Attribute
{
///
/// Order or the arguments. The lowest value comes first.
///
public int Order { get; set; }
///
/// The name of the property. This will be shown in the CLI usage output.
///
public string Name { get; private set; }
///
/// Indicates whether this argument is required or optional. If it's a string[] and required then this indicates that it needs at least one value.
///
public bool Required { get; set; }
///
/// Human readable description of the argument.
///
public string Description { get; set; }
///
/// Constructor.
///
///
public UnnamedCommandLineArgument(string name)
{
this.Name = name;
Order = 0;
Required = false;
}
}
}