Class SwitchArg

    • Field Detail

      • OS_TO_SWITCH_PATTERN

        public static final Map<OsFamily,​String> OS_TO_SWITCH_PATTERN
      • OS_TO_END_SWITCH_PATTERN

        public static final Map<OsFamily,​String> OS_TO_END_SWITCH_PATTERN
    • Constructor Detail

      • SwitchArg

        public SwitchArg​(int arg,
                         Map<String,​Statement> valueToActions)
        Generates a switch statement based on arg. If its value is found to be a key in valueToActions, the corresponding action is invoked.

        Ex. arg is 1 - the first argument to the script
        and valueToActions is {"start" -> "echo hello", "stop" -> "echo goodbye"}
        the script created will respond accordingly:
        ./script start
        << returns hello
        ./script stop
        << returns goodbye

        Parameters:
        arg - - shell arg to switch on
        valueToActions - - case statements, if the value of the arg matches a key, the corresponding value will be invoked.