Adds an option to a command if it is not empty.

@param  string $option
@param  mixed  $check
@param  bool   $asValue
@param  string $glue
@return \SebastianFeldmann\Cli\Command\Executable
162256
public function addOptionIfNotEmpty(string $option, $check, bool $asValue = true, string $glue = '=') : Executable
    {
        if (!empty($check)) {
            if ($asValue) {
                $this->addOption($option, $check, $glue);
            } else {
                $this->addOption($option);
            }
        }
        return $this;
    }
250221
public static function checkbox($name, $checked = false, $options = [])
    {
        self::exclure($options);

        return self::checked('checkbox', $name, $checked, $options);
    }
101526
public function where($where, $glue = 'AND')
    {
        if(is_array($where) && count($where) != 0) {
            foreach($where as $field => $value) {
                $array[] = " `$field` = ".((is_string($value) ? "'$value'" : $value));
            }
            $this->where = " WHERE".implode(" $glue", $array);
        }
        elseif(is_string($where) && trim($where) != '') {
            $where = trim($where);
            $where = trim($where, 'WHERE ');
            $where = rtrim($where);
            $this->where = ' WHERE '.$where;
        }
        return $this;
    }
928984
private function hasValue(array $check, string $value): bool
    {
        if (empty($check[$value])) {
            return false;
        }

        return true;
    }
358703
private function addToOptionCache(string $identifier, $option) : void
    {
        if (!isset($option[$identifier])) {
            return;
        }
        $cacheKey = "${option['command']}${option[$identifier]}";
        if (!isset($this->optionsCache[$cacheKey])) {
            $this->optionsCache[$cacheKey] = $option;
        } else {
            throw new OptionExistsException(
                "An argument option with $identifier {$option['command']} {$option[$identifier]} already exists."
            );
        }
    }
213631
function aceSwitch( cellvalue, options, cell ) {
		setTimeout(function(){
			$(cell) .find('input[type=checkbox]')
					.wrap('<label class="inline" />')
				.addClass('ace ace-switch ace-switch-5')
				.after('<span class="lbl"></span>');
		}, 0);
	}
852620
public String put(String optionName, String optionValue) {
        options.put(optionName, optionValue);
        return optionValue;
    }
662782
public function addResolvableOption($name, $shortcut = null, $mode = null, $help = null, $default = null)
    {
        $this->opts[] = $name;
        return parent::addOption($name, $shortcut, $mode, $help, $default);
    }
168504
static public function array_as_option_list(array $data, $checkedValue=NULL, $type="select", $useTemplateString=NULL, array $repArr=NULL) {
		$typeArr = array (
			"select"	=> "selected",
			"radio"		=> "checked",
			"checkbox"	=> "checked"
		);
		
		$myType = $typeArr[$type];
		if(is_null($useTemplateString)) {
			//
			$useTemplateString = "\t\t<option value='%%value%%'%%selectedString%%>%%display%%</option>";
		}
		
		$retval = "";
		foreach($data as $value=>$display) {
			//see if it's the value that's been selected.
			$selectedString = "";
			if($value == $checkedValue || $display == $checkedValue) {
				//yep, it's selected.
				$selectedString = " ". $myType;
			}
			
			//create the string.
			$myRepArr = array(
				'value'				=> $value,
				'display'			=> $display,
				'selectedString'	=> $selectedString
			);
			if(is_array($repArr) && is_array($repArr[$value])) {
				//merge the arrays.
				$myRepArr = array_merge($repArr[$value], $myRepArr);
			}
			$addThis = ToolBox::mini_parser($useTemplateString, $myRepArr, "%%", "%%");
			$retval = ToolBox::create_list($retval, $addThis, "\n");
		}
		
		return($retval);
	}
445629
function exportValue(&$submitValues, $assoc = false)
    {
        $value = $this->_findValue($submitValues);
        if (null === $value) {
            $value = $this->getChecked()? $this->getValue(): null;
        } elseif ($value != $this->getValue()) {
            $value = null;
        }
        return $this->_prepareValue($value, $assoc);
    }
669169
public function build($itemName = '', $itemValue = '')
    {
        // Create hidden checkbox
        $fi = new FormInput($this->getHTMLDocument(), 'checkbox', $itemName, $id = '', $class = 'swt_chk', $itemValue, $required = false);
        $this->append($fi);

        // Set checked value for checkbox
        if ($this->active) {
            $fi->attr('checked', 'checked');
        }

        // Add switch
        $switch = $this->getHTMLDocument()->create('div', '', '', 'switch');
        $this->append($switch);

        return $this;
    }
821789
public function option($name, $value) {
		$this->validateName($name);
		return $this->merge([$name => $value]);
	}
1272516
public function addOptions($options = [], $selectedValue = '')
    {
        // Create all options
        foreach ($options as $value => $title) {
            // Create option
            $fi = $this->getHTMLFormFactory()->buildFormElement('option', '', $value, '', '', $title);

            // Check if it's the selected value
            if ($value == $selectedValue) {
                $fi->attr('selected', 'selected');
            }

            // Append option to select
            $this->append($fi);
        }

        // Return FormSelect object
        return $this;
    }
924624
public function having($conditions, $glue='AND')
  {
    if ( is_null($this->having) ){
      $glue = strtoupper($glue);
      $this->having = new Element('HAVING', $conditions, " $glue ");
    }
    else {
      $this->having->append($conditions);
    }

    return $this;
  }
115022
public function execute($name, $option = [])
    {
        if (is_string($name)) {
            $names = explode(self::SEPARATOR, $name);
            $method = array_pop($names);
            $task = $this->get($name);
        }

        $task->execute($option);
    }
180410
public function process(GetOpt $getopt, callable $setOption, callable $setCommand, callable $addOperand)
    {
        while (($arg = array_shift($this->arguments)) !== null) {
            if ($this->isMeta($arg)) {
                // everything from here are operands
                foreach ($this->arguments as $argument) {
                    $addOperand($argument);
                }
                break;
            }

            if ($this->isValue($arg)) {
                $operands = $getopt->getOperands();
                if (empty($operands) && $command = $getopt->getCommand($arg)) {
                    $setCommand($command);
                } else {
                    $addOperand($arg);
                }
            }

            if ($this->isLongOption($arg)) {
                $setOption($this->longName($arg), function (Option $option = null) use ($arg) {
                    return $this->value($arg, null, $option);
                });
                continue;
            }

            // the only left is short options
            foreach ($this->shortNames($arg) as $name) {
                $requestedValue = false;
                $setOption($name, function (Option $option = null) use ($arg, $name, &$requestedValue) {
                    $requestedValue = true;
                    return $this->value($arg, $name, $option);
                });

                if ($requestedValue) {
                    // when there is a value it was the last option
                    break;
                }
            }
        }
        return true;
    }
1073853
public function constructSQLClause($glue, array $columns)
    {
        $whereClause = [];

        foreach ($columns as $column => $value) {
            $newValue = ltrim($value, '!');
            $quotedValue = $this->quoteOrNot($newValue);
            $comparator = '%s=';
            $notOperator = '';

            // Check if the supplied value is null, if so change the format.
            if (strtolower($newValue) == 'null') {
                $comparator = 'is%s';
            }

            // Check if a not is applied to the value.
            if ($newValue !== $value) {
                if (strtolower($newValue) == 'null') {
                    $notOperator = ' not';
                } else {
                    $notOperator = '!';
                }
            }

            // Check if the value is surrounded by wildcards. If so, we'll want to use a LIKE comparator.
            if (preg_match('/^%.+%$/', $value)) {
                $comparator = 'LIKE';
            }

            // Make up the sql.
            $comparator = sprintf($comparator, $notOperator);

            $whereClause[] = sprintf('%s %s %s', $column, $comparator, $quotedValue);
        }

        return implode($glue, $whereClause);
    }