PeanutButter
Loading...
Searching...
No Matches
PeanutButter.EasyArgs.CommandlineArgument Class Reference

Describes a command line argument. More...

Public Member Functions

bool HasSwitch (string sw)
 shortcut to determine if the switch is either the long or short switch for this arg
CommandlineArgument CloneNegated ()
 Produces a copy of the current argument, negated Used when generating –no-{arg} flags.

Static Public Attributes

const string HELP_FLAG_KEY = "$help$"
 Explicit key for the help argument.

Properties

string LongName [get, set]
 The long name of the argument (eg 'remote-server')
string ShortName [get, set]
 The short name of the argument (eg 'r'), constrained to one char by the [ShortName] attribute.
string Description [get, set]
 The description of the argument which is displayed in help text.
string LongSwitch [get]
 Provides a convenience reader for the –{LongName} switch.
string ShortSwitch [get]
 Provides a convenience reader for the -{ShortName} switch.
string Type [get]
 The type of argument for help display (typically "text" or "number")
string PropertyName [get]
 Exposes the property name for debugging.
decimal? MinValue [get, set]
 Minimum value for a numeric argument.
decimal? MaxValue [get, set]
 Maximum value for a numeric argument.
bool VerifyFileExists [get, set]
 Flag: if this is a string value and not null or empty, verify that the file exists.
bool VerifyFolderExists [get, set]
 Flag: if this is a string value and not null or empty, verify that the folder exists.
PropertyInfo Property [get, set]
 The corresponding PropertyInfo for this argument.
string Key [get, set]
 The fully-qualified name of the argument.
object Default [get, set]
 Default value for this argument.
bool IsImplicit [get, set]
 Whether this argument was generated (eg negations / help)
string[] ConflictsWithKeys = new string[0] [get, set]
 Collection of arguments this conflicts with, by Key.
bool AllowMultipleValues [get]
 Whether this argument allows multiple values (and will consume all non-switch values up to the next switch, eg "-foo 1 2 3" would collect the array [ 1, 2, 3 ] if the Foo property is int[].
bool IsFlag [get, set]
 Whether this argument is a flag.
bool IsHelpFlag [get]
 Whether this specific argument is the help one.
bool IsRequired [get, set]
 Whether this argument is required.
bool DisableShortNameGeneration [get, set]
 Disables short-name generation for this argument.
bool IsNegatedFlag [get, set]
 Marker: is this a negated flag?
string EnvironmentDefaultVariable [get, set]
 Set to the name of the environment variable that would be observed to override / set a default value for the option. To enable environmental defaults, either decorate the option with [AllowDefaultFromEnvironment] or decorate the entire options object with [AllowDefaultFromEnvironment]. At the property level, [AllowDefaultFromEnvironment] can be given an explicit environment variable name to look for; otherwise environment variables are matched fuzzily to property names:

Detailed Description

Describes a command line argument.

Member Function Documentation

◆ CloneNegated()

CommandlineArgument PeanutButter.EasyArgs.CommandlineArgument.CloneNegated ( )

Produces a copy of the current argument, negated Used when generating –no-{arg} flags.

Returns

◆ HasSwitch()

bool PeanutButter.EasyArgs.CommandlineArgument.HasSwitch ( string sw)

shortcut to determine if the switch is either the long or short switch for this arg

Parameters
sw
Returns

Property Documentation

◆ EnvironmentDefaultVariable

string PeanutButter.EasyArgs.CommandlineArgument.EnvironmentDefaultVariable
getset

Set to the name of the environment variable that would be observed to override / set a default value for the option. To enable environmental defaults, either decorate the option with [AllowDefaultFromEnvironment] or decorate the entire options object with [AllowDefaultFromEnvironment]. At the property level, [AllowDefaultFromEnvironment] can be given an explicit environment variable name to look for; otherwise environment variables are matched fuzzily to property names:

  • case-insensitive
  • ignoring _ and . so, eg, the env var FOO_BAR or FOO.BAR will populate a property called FooBar or fooBar, etc.

◆ Key

string PeanutButter.EasyArgs.CommandlineArgument.Key
getset

The fully-qualified name of the argument.

  • Property.Name when available
  • $help$ for the generated help argument

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.EasyArgs/CommandlineArgument.cs