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
  • Gets a flag with a name

    Declaration

    Swift

    public subscript(valueForName name: String) -> Any?

    Parameters

    name

    the flag name

    Return Value

    the flag

  • Gets a flag with a name

    Declaration

    Swift

    public subscript(name: String) -> Flag?

    Parameters

    name

    the flag name

    Return Value

    the flag

  • All the flags passed

    Declaration

    Swift

    public var flags: [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: FlagValue>(name: String, type: T.Type) -> T?

    Parameters

    name

    the flag name

    type

    the type of the flag

    Return Value

    the value if the flag is found