Skip to content

Commit

Permalink
Add version discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Mar 25, 2019
1 parent 9852dce commit fb910a0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/ASMP.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace ASMP\WordPressIntegration;

interface ASMP {
public const VERSION = 'ASMP_DISCOVERY_VERSION';

public const VERSION = 'ASMP_DISCOVERY_VERSION';
public const ENDPOINT = 'ASMP_DISCOVERY_ENDPOINT';
}
54 changes: 42 additions & 12 deletions src/Console/AsmpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,38 @@

namespace ASMP\WordPressIntegration\Console;

use ASMP\WordPressIntegration\ASMP;
use WP_CLI;

final class AsmpCommand {

/**
* Run a check against ASMP.
*
* @param array $args Positional arguments.
* @param array $assoc_args Associative arguments.
* @param array $args Optional. Array of positional arguments.
* @param array $assoc_args Optional. Array of associative arguments.
*/
public function check( array $args, array $assoc_args ) {
public function check( array $args, array $assoc_args ): void {
WP_CLI::error( 'Not implemented yet' );
}

/**
* Request a change through ASMP.
*
* @param array $args Positional arguments.
* @param array $assoc_args Associative arguments.
* @param array $args Optional. Array of positional arguments.
* @param array $assoc_args Optional. Array of associative arguments.
*/
public function change( array $args, array $assoc_args ) {
public function change( array $args = [], array $assoc_args = [] ): void {
WP_CLI::error( 'Not implemented yet' );
}

/**
* Roll back a change through ASMP.
*
* @param array $args Positional arguments.
* @param array $assoc_args Associative arguments.
* @param array $args Optional. Array of positional arguments.
* @param array $assoc_args Optional. Array of associative arguments.
*/
public function rollback( array $args, array $assoc_args ) {
public function rollback( array $args = [], array $assoc_args = [] ): void {
WP_CLI::error( 'Not implemented yet' );
}

Expand All @@ -51,10 +52,39 @@ public function rollback( array $args, array $assoc_args ) {
* <id>
* : ID of the change to roll back.
*
* @param array $args Positional arguments.
* @param array $assoc_args Associative arguments.
* @param array $args Optional. Array of positional arguments.
* @param array $assoc_args Optional. Array of associative arguments.
*/
public function status( array $args, array $assoc_args ) {
public function status( array $args = [], array $assoc_args = [] ): void {
WP_CLI::error( 'Not implemented yet' );
}

/**
* Check whether ASMP is available.
*
* @subcommand is-available
* @param array $args Optional. Array of positional arguments.
* @param array $assoc_args Optional. Array of associative arguments.
*/
public function is_available( array $args = [], array $assoc_args = [] ): void {
if ( false === \getenv( ASMP::VERSION ) ) {
exit( 1 );
}

exit( 0 );
}

/**
* Get the supported version of ASMP.
*
* @param array $args Optional. Array of positional arguments.
* @param array $assoc_args Optional. Array of associative arguments.
*/
public function version( array $args = [], array $assoc_args = [] ): void {
if ( ! $this->is_available() ) {
WP_CLI::error( 'ASMP is not available.' );
}

WP_CLI::log( \getenv( ASMP::VERSION ) );
}
}

0 comments on commit fb910a0

Please sign in to comment.