Skip to content

Commit

Permalink
implement ExactlyOnceAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Jun 29, 2016
1 parent 7d1debe commit 6a1389b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Argu/PreCompute.fs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ let rec private preComputeUnionCaseArgInfo (stack : Type list) (helpParam : Help

let isFirst = uci.ContainsAttribute<FirstAttribute> ()
let isAppSettingsCSV = uci.ContainsAttribute<ParseCSVAttribute> ()
let isMandatory = uci.ContainsAttribute<MandatoryAttribute> (true)
let isUnique = uci.ContainsAttribute<UniqueAttribute> (true)
let isExactlyOnce = uci.ContainsAttribute<ExactlyOnceAttribute>(true)
let isMandatory = isExactlyOnce || uci.ContainsAttribute<MandatoryAttribute> (true)
let isUnique = isExactlyOnce || uci.ContainsAttribute<UniqueAttribute> (true)
let isGatherAll = uci.ContainsAttribute<GatherAllSourcesAttribute> ()
let isRest = uci.ContainsAttribute<RestAttribute> ()
let isHidden = uci.ContainsAttribute<HiddenAttribute> ()
Expand Down
5 changes: 5 additions & 0 deletions src/Argu/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ module ArguAttributes =
[<AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Property, AllowMultiple = false)>]
type UniqueAttribute () = inherit Attribute ()

/// Demands that the argument should be specified exactly once; an exception is raised otherwise.
/// Equivalent to attaching both the Mandatory and Unique attribute on the parameter.
[<AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Property, AllowMultiple = false)>]
type ExactlyOnceAttribute () = inherit Attribute ()

/// Gathers all parsed results from both AppSettings and command line.
[<AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Property, AllowMultiple = false)>]
type GatherAllSourcesAttribute () = inherit Attribute ()
Expand Down

0 comments on commit 6a1389b

Please sign in to comment.