Skip to content

Commit

Permalink
feat: Homebrew (#18)
Browse files Browse the repository at this point in the history
homebrew support

add homebrew instructions on install section
change self-update to check for homebrew instalation and give proper instructions

Co-authored-by: Leo Cavalcante <lc@leocavalcante.com>
  • Loading branch information
neuberoliveira and leocavalcante authored Feb 7, 2024
1 parent f521b0e commit 6b2aa1f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Take the advantage of goodie commands like `phpctl create` to start a new projec
- Docker

### Install
If you want to install it system-wide (at `/usr/local/bin`), run:
You can install with default installer script for a system-wide (at `/usr/local/bin`), run:
```shell
wget -q https://phpctl.dev/phpctl-installer.sh && \
bash phpctl-installer.sh && rm phpctl-installer.sh
Expand All @@ -43,12 +43,19 @@ bash phpctl-installer.sh && rm phpctl-installer.sh
> bash phpctl-installer.sh ~/bin
> ```
Homebrew
`brew install opencodeco/phpctl/phpctl`
Or add the `oppencodeco` tap with `brew tap opencodeco/phpctl` and then `brew install phpctl`
#### Update
You can re-run the installer or use the `self-update` command:
```shell
phpctl self-update
```
For those using Homebrew `brew upgrade opencodeco/phpctl/phpctl` or when run `brew update`

## Usage
Then you can use `phpctl` or `pctl` with a subcommand:
```shell
Expand Down
16 changes: 16 additions & 0 deletions src/self-update.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
is_brew_installed() {
command -v brew >/dev/null 2>&1
}

is_tap_installed() {
local tap_name="$1"
brew tap | grep -q "^$tap_name$"
}

self-update() {
local tap_to_check="opencodeco/phpctl"
local full_tap_pkg="$tap_to_check/phpctl"

if is_brew_installed && is_tap_installed "$tap_to_check"; then
echo -e "\033[32mSeems phpctl was installed by Homebrew, to update it run\033[0m brew upgrade $full_tap_pkg"
else
echo -e "Heading to \033[33m$PHPCTL_DIR\033[0m to update..."
cd "$PHPCTL_DIR" || exit 1
git pull origin HEAD
echo -e "\033[32mUpdated!\033[0m"
fi
}

0 comments on commit 6b2aa1f

Please sign in to comment.