library/Garp/Cli/Command/Snippet.php
protected function _createInteractive() {
        Garp_Cli::lineOut('Please provide the following values');
        $data = array(
            'identifier' => Garp_Cli::prompt('Identifier')
        );
        if ($snippet = $this->_fetchExisting($data['identifier'])) {
            Garp_Cli::lineOut('Snippet already exists. Id: #' . $snippet->id, Garp_Cli::GREEN);
            return true;
        }

        $data['uri'] = Garp_Cli::prompt('Url');
        $checks = array(
            array('has_name', 'Does this snippet have a name?', 'y'),
            array('has_html', 'Does this snippet contain HTML?', 'y'),
            array('has_text', 'Does this snippet contain text?', 'n'),
            array('has_image', 'Does this snippet have an image?', 'n'),
        );
        foreach ($checks as $check) {
            $key = $check[0];
            $question = $check[1];
            $default = $check[2];
            if ($default == 'y') {
                $question .= ' Yn';
            } elseif ($default == 'n') {
                $question .= ' yN';
            }
            $userResponse = trim(Garp_Cli::prompt($question));
            if (!$userResponse) {
                $userResponse = $default;
            }
            if (strtolower($userResponse) == 'y' || $userResponse == 1) {
                $data[$key] = 1;
            } elseif (strtolower($userResponse) == 'n' || $userResponse == 0) {
                $data[$key] = 0;
            }
        }

        $snippet = $this->_create($data);
        Garp_Cli::lineOut(
            'New snippet inserted. Id: #' . $snippet->id . ', Identifier: "' .
            $snippet->identifier . '"'
        );
        return true;
    }
protected function _createInteractive() {
        Garp_Cli::lineOut('Please provide the following values');
        $data = array(
            'identifier' => Garp_Cli::prompt('Identifier')
        );
        if ($snippet = $this->_fetchExisting($data['identifier'])) {
            Garp_Cli::lineOut('Snippet already exists. Id: #' . $snippet->id, Garp_Cli::GREEN);
            return true;
        }

        $data['uri'] = Garp_Cli::prompt('Url');
        $checks = array(
            array('has_name', 'Does this snippet have a name?', 'y'),
            array('has_html', 'Does this snippet contain HTML?', 'y'),
            array('has_text', 'Does this snippet contain text?', 'n'),
            array('has_image', 'Does this snippet have an image?', 'n'),
        );
        foreach ($checks as $check) {
            $key = $check[0];
            $question = $check[1];
            $default = $check[2];
            if ($default == 'y') {
                $question .= ' Yn';
            } elseif ($default == 'n') {
                $question .= ' yN';
            }
            $userResponse = trim(Garp_Cli::prompt($question));
            if (!$userResponse) {
                $userResponse = $default;
            }
            if (strtolower($userResponse) == 'y' || $userResponse == 1) {
                $data[$key] = 1;
            } elseif (strtolower($userResponse) == 'n' || $userResponse == 0) {
                $data[$key] = 0;
            }
        }

        $snippet = $this->_create($data);
        Garp_Cli::lineOut(
            'New snippet inserted. Id: #' . $snippet->id . ', Identifier: "' .
            $snippet->identifier . '"'
        );
        return true;
    }
protected function _createInteractive ( ) { Garp_Cli :: lineOut ( 'Please provide the following values' ) ; $ data = array ( 'identifier' => Garp_Cli :: prompt ( 'Identifier' ) ) ; if ( $ snippet = $ this -> _fetchExisting ( $ data [ 'identifier' ] ) ) { Garp_Cli :: lineOut ( 'Snippet already exists. Id: #' . $ snippet -> id , Garp_Cli :: GREEN ) ; return true ; } $ data [ 'uri' ] = Garp_Cli :: prompt ( 'Url' ) ; $ checks = array ( array ( 'has_name' , 'Does this snippet have a name?' , 'y' ) , array ( 'has_html' , 'Does this snippet contain HTML?' , 'y' ) , array ( 'has_text' , 'Does this snippet contain text?' , 'n' ) , array ( 'has_image' , 'Does this snippet have an image?' , 'n' ) , ) ; foreach ( $ checks as $ check ) { $ key = $ check [ 0 ] ; $ question = $ check [ 1 ] ; $ default = $ check [ 2 ] ; if ( $ default == 'y' ) { $ question .= ' Yn' ; } elseif ( $ default == 'n' ) { $ question .= ' yN' ; } $ userResponse = trim ( Garp_Cli :: prompt ( $ question ) ) ; if ( ! $ userResponse ) { $ userResponse = $ default ; } if ( strtolower ( $ userResponse ) == 'y' || $ userResponse == 1 ) { $ data [ $ key ] = 1 ; } elseif ( strtolower ( $ userResponse ) == 'n' || $ userResponse == 0 ) { $ data [ $ key ] = 0 ; } } $ snippet = $ this -> _create ( $ data ) ; Garp_Cli :: lineOut ( 'New snippet inserted. Id: #' . $ snippet -> id . ', Identifier: "' . $ snippet -> identifier . '"' ) ; return true ; }
Create snippet interactively

@return bool
Create snippet interactively