<?php

App::uses('AppShell', 'Console/Command');
App::uses('Security', 'Utility');

/**
 * Bemmelhor Shell
 *
 * PHP version 5
 *
 * @category Shell
 * @package  Bemmelhor
 * @version  1.0
 * @author   Fabricio S Costa <fabriciojf@gmail.com>
 *
 * @link     http://www.bemmelhor.org
 */
class BemmelhorShell extends AppShell {

    /**
     * Display help/options
     */
    public function getOptionParser() {
        $parser = parent::getOptionParser();
        $parser->description(__('Bemmelhor Utilities')
        )->addSubcommand('password', array(
            'help' => 'Get hashed password',
            'parser' => array(
                'description' => 'Get hashed password',
                'arguments' => array(
                    'password' => array(
                        'required' => true,
                        'help' => 'Password to hash',
                    ),
                ),
            ),
                )
        );
        return $parser;
    }

    /**
     * Get hashed password
     *
     * Usage: ./Console/cake bemmelhor password myPasswordHere
     */
    public function password() {
        $value = trim($this->args['0']);
        $this->out(Security::hash($value, null, true));
    }

}
