Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples in site-command #113

Merged
merged 4 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Site_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
use EE\Dispatcher\CommandFactory;
use EE\Model\Site;

/**
* Adds site related functionality to EasyEngine
*/
class Site_Command {

/**
Expand All @@ -11,14 +14,14 @@ class Site_Command {
protected static $site_types = [];

/**
* @var Object $instance Hold an instance of the class.
* @var Site_Command $instance Hold an instance of the class.
*/
private static $instance;

/**
* The singleton method to hold the instance of site-command.
*
* @return Object|Site_Command
* @return Site_Command
*/
public static function instance() {

Expand Down Expand Up @@ -99,6 +102,8 @@ public function __invoke( $args, $assoc_args ) {
*
* @param array $args Command line arguments passed to site-command.
*
* @throws \EE\ExitException
*
* @return string site-type.
*/
private function determine_type( $args ) {
Expand Down
61 changes: 54 additions & 7 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace EE\Site\Type;

use function EE\Site\Utils\reload_global_nginx;
use \Symfony\Component\Filesystem\Filesystem;
use \EE\Model\Site;
use function \EE\Site\Utils\auto_site_name;
use function \EE\Site\Utils\get_site_info;
use function \EE\Site\Utils\reload_global_nginx_proxy;
use EE\Model\Site;
use Symfony\Component\Filesystem\Filesystem;
use function EE\Site\Utils\auto_site_name;
use function EE\Site\Utils\get_site_info;
use function EE\Site\Utils\reload_global_nginx_proxy;

/**
* Base class for Site command
Expand Down Expand Up @@ -73,6 +72,23 @@ public function __construct() {
* - text
* ---
*
* ## EXAMPLES
*
* # List all sites
* $ ee site list
*
* # List enabled sites
* $ ee site list --enabled
*
* # List disabled sites
* $ ee site list --disabled
*
* # List all sites in JSON
* $ ee site list --format=json
*
* # Count all sites
* $ ee site list --format=count
*
* @subcommand list
*/
public function _list( $args, $assoc_args ) {
Expand Down Expand Up @@ -127,6 +143,12 @@ function ( $site ) {
*
* [--yes]
* : Do not prompt for confirmation.
*
* ## EXAMPLES
*
* # Delete site
* $ ee site delete example.com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a new PR:
Add example which skips the prompt using --yes flag.

*
*/
public function delete( $args, $assoc_args ) {

Expand All @@ -140,14 +162,16 @@ public function delete( $args, $assoc_args ) {
/**
* Function to delete the given site.
*
* @param int $level Level of deletion.
* @param int $level Level of deletion.
* Level - 0: No need of clean-up.
* Level - 1: Clean-up only the site-root.
* Level - 2: Try to remove network. The network may or may not have been created.
* Level - 3: Disconnect & remove network and try to remove containers. The containers
* may not have been created. Level - 4: Remove containers. Level - 5: Remove db entry.
* @param string $site_url Name of the site to be deleted.
* @param string $site_fs_path Webroot of the site.
*
* @throws \EE\ExitException
*/
protected function delete_site( $level, $site_url, $site_fs_path ) {

Expand Down Expand Up @@ -221,6 +245,12 @@ protected function delete_site( $level, $site_url, $site_fs_path ) {
*
* [--force]
* : Force execution of site up.
*
* ## EXAMPLES
*
* # Enable site
* $ ee site up example.com
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add example to re-enable and already enabled site using --force flag.

*/
public function up( $args, $assoc_args ) {

Expand Down Expand Up @@ -252,6 +282,12 @@ public function up( $args, $assoc_args ) {
*
* [<site-name>]
* : Name of website to be disabled.
*
* ## EXAMPLES
*
* # Disable site
* $ ee site down example.com
*
*/
public function down( $args, $assoc_args ) {

Expand Down Expand Up @@ -284,6 +320,12 @@ public function down( $args, $assoc_args ) {
*
* [--nginx]
* : Restart nginx container of site.
*
* ## EXAMPLES
*
* # Restart all containers of site
* $ ee site restart example.com
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add example to restart specific containers.

*/
public function restart( $args, $assoc_args, $whitelisted_containers = [] ) {

Expand Down Expand Up @@ -321,6 +363,11 @@ public function restart( $args, $assoc_args, $whitelisted_containers = [] ) {
* [--nginx]
* : Reload nginx service in container.
*
* ## EXAMPLES
*
* # Reload all containers of site
* $ ee site reload example.com
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add example to reload specific containers.

*/
public function reload( $args, $assoc_args, $whitelisted_containers = [], $reload_commands = [] ) {

Expand Down
34 changes: 24 additions & 10 deletions src/site-type/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@

namespace EE\Site\Type;

use \EE\Model\Site;
use \Symfony\Component\Filesystem\Filesystem;
use function \EE\Site\Utils\auto_site_name;
use function \EE\Site\Utils\get_site_info;
use EE\Model\Site;
use Symfony\Component\Filesystem\Filesystem;
use function EE\Site\Utils\auto_site_name;
use function EE\Site\Utils\get_site_info;

/**
* Creates a simple html Website.
*
* ## EXAMPLES
*
* # Create simple html site
* $ ee site create example.com
* Adds html site type to `site` command.
*
* @package ee-cli
*/
Expand Down Expand Up @@ -73,11 +68,24 @@ public function __construct() {
*
* [--wildcard]
* : Gets wildcard SSL .
*
* [--type=<type>]
* : Type of the site to be created. Values: html,php,wp etc.
*
* [--skip-status-check]
* : Skips site status check.
*
* ## EXAMPLES
*
* # Create html site
* $ ee site create example.com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add --type=html in this. If the default site type is configured to some other site-type then this will fail.

*
* # Create html site with ssl from letsencrypt
* $ ee site create example.com --ssl=le
*
* # Create html site with wildcard ssl
* $ ee site create example.com --ssl=le --wildcard
*
*/
public function create( $args, $assoc_args ) {

Expand Down Expand Up @@ -111,6 +119,12 @@ public function create( $args, $assoc_args ) {
*
* [<site-name>]
* : Name of the website whose info is required.
*
* ## EXAMPLES
*
* # Display site info
* $ ee site info example.com
*
*/
public function info( $args, $assoc_args ) {

Expand Down