Custom Command - hiberus-magento/hiberus-dockergento GitHub Wiki

⚙️ Create a custom command for a specific project

Add script file.

Create a file in path ./config/hm/commands/my-custom-commmand.sh.

mkdir -p ./config/hm/commands
cd $_
touch my-custom-commmand.sh
chmod +x my-custom-commmand.sh

Add script. For example:

#!/usr/bin/env bash

echo "--------- My custom command ---------"

Add description file.

Create a file for your command description ./config/hm/commands/command_descriptions.json

{
	"my-custom-command": {
		"usage": "my-custom-command [OPTIONS] [ARGUMENTS]",
		"example": "my-custom-command -o=3",
		"description": "Command description",
		"opts": [
			{
				"name": {
					"short": "o",
					"long": "option"
				},
				"description": "Argument description"
			}
		],
		"args": [
			{
				"name": "Argument name",
				"description": "Argument description"
			}
		]
	}
},

Check your command

  • Execute hm -h . In a new section you can see the description of your command
  • Execute hm <custom-command> .

You can use variable of hm CLI like

variable description
$DOMAN domain of your current project
$COMMAND_DIR command directory path

Example

#!/usr/bin/env bash

if [ -e "./vendor/magento" ](/hiberus-magento/hiberus-dockergento/wiki/--e-"./vendor/magento"-);then
	"$COMMAND_DIR"/start.sh
	"$COMMAND_DIR"/purge.sh
	"$COMMAND_DIR"/magento.sh cache:clean
	"$COMMAND_DIR"/stop.sh
fi