Ejemplo n.º 1
0
        private string GetShortName()
        {
            string attributeShortName = AttributeProvider.GetCustomAttribute <OptionAttribute>()?.ShortName;

            if (!string.IsNullOrEmpty(attributeShortName)) //provided by user
            {
                return(attributeShortName);
            }

            //use parameter name as short name
            return(PropertyOrArgumentName.Length == 1 ? PropertyOrArgumentName.ChangeCase(Settings.Case) : null);
        }
Ejemplo n.º 2
0
        private BooleanMode GetBooleanMode()
        {
            OptionAttribute attribute = AttributeProvider.GetCustomAttribute <OptionAttribute>();

            if (attribute == null || attribute.BooleanMode == BooleanMode.Unknown)
            {
                return(Settings.BooleanMode);
            }

            return(UnderlyingType == typeof(bool)
                ? attribute.BooleanMode
                : throw new AppRunnerException(
                       $"BooleanMode property is set to `{attribute.BooleanMode}` for a non boolean parameter type. " +
                       $"Property name: {PropertyOrArgumentName} " +
                       $"Type : {Type.Name}"));
        }
Ejemplo n.º 3
0
        private string GetLongName()
        {
            string attributeLongName = AttributeProvider.GetCustomAttribute <OptionAttribute>()?.LongName;

            if (!string.IsNullOrEmpty(attributeLongName)) //long name attribute provided by user
            {
                return(attributeLongName);
            }

            //short name is not present,
            if (string.IsNullOrEmpty(ShortName) && PropertyOrArgumentName.Length > 1)
            {
                return(PropertyOrArgumentName.ChangeCase(Settings.Case)); //return parameter name as long name
            }
            //there is no long name
            return(null);
        }
Ejemplo n.º 4
0
 private string GetAnnotatedDescription()
 {
     return(AttributeProvider.GetCustomAttribute <ArgumentAttribute>()?.Description);
 }
        protected override string GetAnnotatedDescription()
        {
            ArgumentAttribute descriptionAttribute = AttributeProvider.GetCustomAttribute <ArgumentAttribute>();

            return(descriptionAttribute?.Description);
        }