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

Homebrew support #18

Merged
merged 2 commits into from
Feb 7, 2024
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: 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
}
Loading