CLI Usage Run Through - nathan-fiscaletti/synful GitHub Wiki

Creating a custom command

You can create your own CLI command by using the following command:

$ ./synful -create-command MyCommand

This will create the custom command in ./src/Synful/App/Commands.

Note: You will need to register the command in ./config/CommandLine.json in order to use it.

$ ./synful -register command MyCommand

When you create a custom command, you can either execute some logic and then return parameter_result_halt(); to stop the process, or you can return a result and access it anywhere in the framework using Synful::$command_results as an array.

See ParameterParser: Example 7: Halting the Parser

Example

. . . 
$this->name = 'cmd';
$this->description = 'My Command.';
$this->required = false;
$this->alias = 'command';

$this->exec = function ($value) {
    return $value;
};
. . . 

$value = Synful::$commmand_results['cmd'];

Note: The key in $command_results will be the name property of your command, and never the alias.

Built In Commands

Usage: ./synful [options]

Options:

External

Note: These commands are run outside of the primary Synful process.

Command Alias Parameters Description
install Installs all dependencies for Synful and executes ./synful -ct to create the default tables. For this to work properly, the default Synful database must already be configured. (See Database Management)
update Updates the dependencies for Synful
vagrant If a vagrant environment is already up, this will destroy it. If one is not up, this will bring up a new Vagrant environment

API Key Management (See API Key Management)

Command Alias Parameters Description
-ck -create-key [auth] [name] [security_level] [whitelist_only] [rate_limit] [rate_limit_seconds] Creates a new API key with the specified information.(See Rate Limiting)
-epm -end-point-manager [action] [auth] [endpoint] Adds or removes an endpoint to an API keys Endpoint Access Array.
-dk -disable-key [auth_or_id] Disables a key (making it unable to be used) based on authentication handle or ID.
-ek -enable-key [auth_or_id] Enables a key that has been disabled based on authentication handle or ID.
-lk -list-keys Outputs a list of all API Keys.
-rk -remove-key [auth_or_id] Removes a key from the System based on authentication handle or ID.
-ta -test-auth [auth] [key] Test authentication for an API key.
-uk -update-key [auth_or_id] Generates a new private key for an API Key.
-w -white-list-only [auth_or_id] [value] Enables or disables the 'White-List Only' Option for the specified key.

Firewall Management

Command Alias Parameters Description
-f -firewall-ip [auth_or_id] [ip] [block_value] Firewalls an IP Address on the specified key with the specified block value.
-sf -show-firewall [auth_or_id] Lists firewall entries for a specific key.
-uf -unfirewall-ip [auth_or_id] [ip] Removes the firewall entry for the specified ip on the specified key.

Database

Command Alias Parameters Description
-cmi -create-migration [name] Create a database migration.
-cm -create-model [name] [database] Create a database model.
-mi -migrate [action] Run database migrations.

Other Commands

Command Alias Parameters Description
-cc -create-command [name] Create a new command.
-cl -color [bool] Use to enable/disable console color at run time.
-ch -create-handler [name] Creates a request handler with the specified name in src/Synful/App/RequestHandlers.
-cmw -create-middleware [name] Creates a new Middleware implementation with the specified name in src/Synful/App/MiddleWare.
-cs -create-serializer [name] Creates a new Serializer implementation with the specified name in src/Synful/App/Serializers.
-reg -register [requesthandler command][name]
-h -help Displays usage and descriptions for all comamnd line parameters.
-hc -hide-config [bool] Used to hide config change messages on initialization.
-lrh -list-request-handlers List all RequestHandlers currently registered in the System.
-o -output [level] Minimizes output when creating or updating api keys. Must be set first.
-v -version Shows the current frameworks version number.