Flags

public struct Flags

Flags represent an abstraction on a list of flags It provides method to get the flags by name And functions to get int, string, bool and custom types


Example

// flags: Flags
flags.getInt(name: "verbose") // return integer value of flag verbose if possible
flags.getBool(name: "verbose") // return boolean value of flag verbose if possible
flags.getString(name: "user") // return string value of flag user if possible
flags.get(name: "debug", type: YourType.self) // get the value of debug if it is of YourType
  • All the flags passed

    Declaration

    Swift

    public var flags: [Flag] { get }
  • Gets a flag with a name

    Declaration

    Swift

    public subscript(name: String) -> Flag? { get }

    Parameters

    name

    the flag name

    Return Value

    the flag

  • Gets a flag with a name

    Declaration

    Swift

    public subscript(valueForName name: String) -> FlagValue? { get }

    Parameters

    name

    the flag name

    Return Value

    the flag

  • Gets a flag with a name

    Declaration

    Swift

    public subscript(valuesForName name: String) -> [FlagValue]? { get }

    Parameters

    name

    the flag name

    Return Value

    the flag

  • Gets an integer value for a flag

    Declaration

    Swift

    public func getInt(name: String) -> Int?

    Parameters

    name

    the flag name

    Return Value

    the value if the flag is found

  • Gets a bool value for a flag

    Declaration

    Swift

    public func getBool(name: String) -> Bool?

    Parameters

    name

    the flag name

    Return Value

    the value if the flag is found

  • Gets a string value for a flag

    Declaration

    Swift

    public func getString(name: String) -> String?

    Parameters

    name

    the flag name

    Return Value

    the value if the flag is found

  • Get a value for a type

    Declaration

    Swift

    public func get<T>(name: String, type: T.Type) -> T? where T : FlagValue

    Parameters

    name

    the flag name

    type

    the type of the flag

    Return Value

    the value if the flag is found

  • Get an array of values for a type

    Declaration

    Swift

    public func get<T>(name: String, type: [T].Type) -> [T]? where T : FlagValue

    Parameters

    name

    the flag name

    type

    the array type of the flag

    Return Value

    the values if the flag is found