wp db export
Will output something like
Succes: Exported to 'dbname-2018-09-16-2790c11.sql'
Often you need the filename.
--porcelain flag to the rescue!
wp db export --porcelain
This will work on a lot of commands that have one item output.
wp post create ....
Here is a complete list of commands that have the –porcelain flag
Commands that output more items usually have a
--format flag to handle output.
wp-cli can be used to execute a php file with the eval-file command.
Biggest plus; WordPress is loaded when you execute that file.
The point it will call this file is after the init action and after the later wp_loaded action.
Installing wp-cli with 2 command:
wget https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash -O ~/wp-completion.bash -q
echo "source $HOME/wp-completion.bash" >> ~/.bashrc
And logout then login again for it to take effect.