Search code examples
cakephpcakephp-2.0cake-console

cakephp console without prompt (-f option?)


Some CakeConsole commands (such as schema update) needs to confirm the operation by user. (Are you sure… messages)

I want to use it under Puppet (automatic installation) so there is no actual user to enter yes for confirmation.

Is there any option to force console to do it? Without asking user?


Solution

  • There's an option for that

    --yes, -y Do not prompt for confirmation. Be careful!

    -> app/Console/cake schema update --help
    
    Welcome to CakePHP v2.8.0-dev Console
    ---------------------------------------------------------------
    App : app
    Path: /var/www/someapp.dev/
    ---------------------------------------------------------------
    Usage:
    cake schema update [options]
    
    Options:
    
    --help, -h        Display this help.
    --verbose, -v     Enable verbose output.
    --quiet, -q       Enable quiet output.
    --plugin, -p      The plugin to use.
    --path            Path to read and write schema.php (default:
                      /var/www/someapp.dev/app/Config/Schema)
    --file            File name to read and write.
    --name            Classname to use. If its Plugin.class, both name and
                      plugin options will be set.
    --connection, -c  Set the db config to use. (default:
                      default)
    --dry             Perform a dry run on create and update commands.
                      Queries will be output instead of run.
    --snapshot, -s    Snapshot number to use/make.
    --force, -f       Force "generate" to create a new schema
    --yes, -y         Do not prompt for confirmation. Be careful!
    

    However the yes option wasn't added until 2.5 - if you're using an earlier version of 2.x, you'll need to upgrade to have this option available.