************** Shell commands ************** .. highlight:: console A number of administration tasks can be performed via shell. All shells and commands listed below can be invoked via a binary that's located in the :file:`bin/` directory. The basic syntax is:: $ bin/cake SHELL [COMMAND] [argument1 argument2 ...] [--option1 --option2=val ...] .. warning:: Windows users must use ``bin\cake`` instead (note the backslash). For instance, if you want to run the :ref:`shell:bedita:setup` command in the :ref:`shell:bedita` shell you can run:: $ bin/cake bedita setup If you want to run the :ref:`shell:db_admin:init` command in the :ref:`shell:db_admin` shell with a couple of additional options you can run:: $ bin/cake db_admin init --no-force --seed .. note:: `Bash autocomplete `_ might come in handy .. _shell:bedita: ``bedita`` ========== The ``bedita`` shell is the first place you'll ever want to search in when you're looking for a tool to perform an administrative task. .. _shell:bedita:setup: ``setup`` --------- The ``setup`` subcommand will lead you through the several steps required to get a new BEdita instance to work. You'll be asked for database connection credentials, as well as user credentials for the first administrator user to be added to the system. Additional steps, like checking for correct permissions on some folders, creating database tables, or checking if current database schema is up-to-date with the latest changes, are performed. **It is safe to run this command again once BEdita has been initialized.** .. program:: bedita setup .. option:: -y, --yes Run in non-interactive mode. .. option:: --config-file Path to configuration file (default: :file:`config/app.php`). Example :: $ bin/cake bedita setup .. _shell:db_admin: ``db_admin`` ============ The ``db_admin`` shell is specialized in database administration tasks for developers. As a user of BEdita, you'll hardly need any of the commands that this shell provides. .. _shell:db_admin:init: ``init`` -------- This subcommand will initialize the database. The database connection **must** be already configured in order for this command to work. If you're looking for a command-line wizard to guide you through all the steps required to install BEdita, please head to the :ref:`setup command `. If any table is present in the database, you'll be asked if you want your database to be weeped, or if you wish to abort the operation. When the schema has been created, you'll also be asked if you want additional set of data to be loaded into the database. A minimum set of data is loaded regardless of your choice --- this is required in order for BEdita to work. This command can be run in unattended (non-interactive) mode by appending command-line flags ``--[no-]force`` and ``--[no-]seed``. .. program:: db_admin init .. option:: -f, --force Force removal of all tables in case target database is not empty. .. option:: --no-force Abort if target database is not empty. .. option:: -s, --seed Seed database with additional set of data. .. option:: --no-seed Don't load any additional set of data. A minimum set of data required for BEdita to work is loaded anyway. .. option:: -c , --connection Database connection to be used (default: ``default``). Example :: $ bin/cake db_admin init --no-force --seed .. _shell:db_admin:check_schema: ``check_schema`` ---------------- This subcommand will perform checks on the current schema. This command is mostly useful when developing features that require making changes to the schema of BEdita's database. You'll be notified of: - migration history not in sync (schema not migrated to the latest available version) - new changes (added or removed tables; changes to columns, indexes or constraints) - naming that offends SQL conventions This command exits with a non-zero exit code whenever current schema is not completely up-to-date and it follows SQL conventions, making it possible to employ this command in other automated tasks. .. program:: db_admin check_schema .. option:: -c , --connection Database connection to be used (default: ``default``). Example :: $ bin/cake db_admin check_schema --verbose .. _shell:jobs: ``jobs`` ======== The ``jobs`` shell is used to run asynchonous pending jobs stored in `async_jobs` table. .. _shell:jobs:pending: ``pending`` ----------- The ``pending`` subcommand will launch all `pending` jobs waiting to be run. A ``--limit`` option may be used to set a maximum number of jobs to run. .. program:: jobs pending .. option:: -l , --limit Specify maximum number of jobs to run. Example :: $ bin/cake jobs pending -l 10 .. _shell:jobs:run: ``run`` ------- The ``run`` subcommand will launch a single job from its UUID. .. program:: jobs run Example :: $ bin/cake jobs run 0660d795-d1bf-4ca0-9a05-2ee47943a658 .. _shell:spec: ``spec`` ======== The ``spec`` shell can be used to automatically generate piece of documentation for available API endpoints. .. _shell:spec:generate: ``generate`` ------------ The ``generate`` subcommand will generate Swagger documentation in YAML format for currently available API endpoints. .. program:: spec generate .. option:: -o , --output Specify an output file (default: :file:`plugins/BEdita/API/spec/be4.yaml`). Example :: $ bin/cake spec generate .. _shell:tree: ``tree`` ======== The ``tree`` shell provides two tasks: ``check`` and ``recover``. .. _shell:tree:check: check ----- It performs some object-aware checks such as: - detect folders that are not in the tree - detect ubiquitous folders - detect non-folder objects that are roots - detect non-folder objects that have descendants - detect objects that are present more than once within same parent Usage: ``bin/cake tree check``. .. _shell:tree:recover: recover ------- It performs a basic recovery of a corrupt tree, by simply invoking CakePHP's TreeBehavior::recover(). Usage: ``bin/cake tree recover``.