Development

Changeset 8418

You must first sign up to be able to contribute.

Changeset 8418

Show
Ignore:
Timestamp:
04/11/08 16:23:17 (2 years ago)
Author:
fabien
Message:

renamed task:init to generate:task, removed detailed_description option

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/task/generator/sfGenerateTaskTask.class.php

    r8404 r8418  
    1616 * @author     Francois Zaninotto <francois.zaninotto@symfony-project.com> 
    1717 */ 
    18 class sfTaskInitTask extends sfBaseTask 
     18class sfGenerateTaskTask extends sfBaseTask 
    1919{ 
    2020  /** 
     
    2323  protected function configure() 
    2424  { 
    25     $this->addArgument('task_name', sfCommandArgument::REQUIRED, 'The task name (can contain namespace)'); 
    26     $this->addOption('dir', null, sfCommandOption::PARAMETER_OPTIONAL, 'The directory to create the task in', 'lib/task'); 
    27     $this->addOption('use_database', 'db', sfCommandOption::PARAMETER_OPTIONAL, 'Whether the task needs model initialization to access database', 'true'); 
    28     $this->addOption('brief_description', 'bd', sfCommandOption::PARAMETER_OPTIONAL, 'A brief task description (appears in task list)', ''); 
    29     $this->addOption('detailed_description', 'dd', sfCommandOption::PARAMETER_OPTIONAL, 'A usage description (shown in help)', ''); 
     25    $this->addArguments(array( 
     26      new sfCommandArgument('task_name', sfCommandArgument::REQUIRED, 'The task name (can contain namespace)'), 
     27    )); 
    3028 
    31     $this->namespace = 'task'; 
    32     $this->name = 'init'; 
     29    $this->addOptions(array( 
     30      new sfCommandOption('dir', null, sfCommandOption::PARAMETER_OPTIONAL, 'The directory to create the task in', 'lib/task'), 
     31      new sfCommandOption('use_database', 'db', sfCommandOption::PARAMETER_OPTIONAL, 'Whether the task needs model initialization to access database', 'true'), 
     32      new sfCommandOption('brief_description', 'bd', sfCommandOption::PARAMETER_OPTIONAL, 'A brief task description (appears in task list)', ''), 
     33    )); 
     34 
     35    $this->namespace = 'generate'; 
     36    $this->name = 'task'; 
    3337    $this->briefDescription = 'Creates a skeleton class for a new task'; 
    3438 
    3539    $this->detailedDescription = <<<EOF 
    36 The [task:init|INFO] creates a new Task class based on the name passed as argument: 
    37   [./symfony task:init namespace:name|INFO] 
     40The [generate:task|INFO] creates a new Task class based on the name passed as argument: 
     41  [./symfony generate:task namespace:name|INFO] 
    3842 
    3943The `fooBarTask.class.php` skeleton task is created under the `lib/task/` directory. Note that the namespace is optional. 
    4044If you want to create the file in another directory (relative to the project root folder), pass it in the [dir|INFO] option: 
    41   [./symfony task:init namespace:name --dir=plugins/myPlugin/lib/task|INFO] 
     45  [./symfony generate:task namespace:name --dir=plugins/myPlugin/lib/task|INFO] 
    4246 
    4347If the task doesn't need database access, you can remove the database initialization code with the [use_database|INFO] option: 
    44   [./symfony task:init namespace:name --use_database=false|INFO] 
     48  [./symfony generate:task namespace:name --use_database=false|INFO] 
    4549 
    4650You can also specify a description: 
    47   [./symfony task:init namespace:name --briefDescription='Does interesting things' --detailedDescription='Usage tutorial'|INFO] 
     51  [./symfony generate:task namespace:name --briefDescription='Does interesting things' --detailedDescription='Usage tutorial'|INFO] 
    4852EOF; 
    4953  } 
     
    6064    $taskClassName = ($namespace ? $namespace.ucfirst($name) : $name) . 'Task'; 
    6165    $briefDescription = $options['brief_description']; 
    62     $detailedDescription = $options['detailed_description'] ? $options['detailed_description'] : <<<HED 
     66    $detailedDescription = <<<HED 
    6367The [$taskName|INFO] task does things. 
    6468Call it with: 
     
    125129  { 
    126130    // add code here 
    127  
    128131  } 
    129132} 
     
    136139      $this->getFilesystem()->mkdirs(str_replace('/', DIRECTORY_SEPARATOR, $options['dir'])); 
    137140    } 
     141 
    138142    $taskFile = sfConfig::get('sf_root_dir').'/'.$options['dir'].'/'.$taskClassName.'.class.php'; 
    139143    if (is_readable($taskFile)) 
    140144    { 
    141       throw new sfCommandException(sprintf('A "%s" task already exists in %s', $taskName, $taskFile)); 
     145      throw new sfCommandException(sprintf('A "%s" task already exists in "%s".', $taskName, $taskFile)); 
    142146    } 
    143      
    144     $this->logSection('init', sprintf('Creating "%s" task file', $taskFile)); 
     147 
     148    $this->logSection('task', sprintf('Creating "%s" task file', $taskFile)); 
    145149    file_put_contents($taskFile, $content); 
    146150  } 
    147  
    148151} 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.