Skip to content

Commit b4b15df

Browse files
committed
feat: rename CLI from hapi to hostinger
BREAKING CHANGE: The CLI is renamed from `hapi` to `hostinger`. The binary, Homebrew formula (`brew install hostinger/tap/hostinger`), config file (`~/.hostinger.yaml`), and environment prefix (`HOSTINGER_API_TOKEN`) are renamed. Existing `~/.hapi.yaml` is auto-migrated to `~/.hostinger.yaml` on first run, and `HAPI_*` env vars still work with a deprecation warning.
1 parent 719d088 commit b4b15df

242 files changed

Lines changed: 2138 additions & 1906 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.goreleaser.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
project_name: hapi
1+
project_name: hostinger
22
version: 2
33

44
before:
55
hooks:
66
- mkdir -p completions
7-
- sh -c 'go run . completion bash > completions/hapi.bash'
8-
- sh -c 'go run . completion zsh > completions/hapi.zsh'
9-
- sh -c 'go run . completion fish > completions/hapi.fish'
7+
- sh -c 'go run . completion bash > completions/hostinger.bash'
8+
- sh -c 'go run . completion zsh > completions/hostinger.zsh'
9+
- sh -c 'go run . completion fish > completions/hostinger.fish'
1010

1111
builds:
1212
- main: ./main.go
@@ -27,24 +27,24 @@ builds:
2727
- linux
2828

2929
archives:
30-
- name_template: "hapi-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
30+
- name_template: "hostinger-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
3131
files:
3232
- completions/*
3333
wrap_in_directory: false
3434

3535
source:
3636
enabled: true
37-
name_template: 'hapi-{{ .Version }}-source'
37+
name_template: 'hostinger-{{ .Version }}-source'
3838

3939
checksum:
40-
name_template: "hapi-{{ .Version }}-checksums.sha256"
40+
name_template: "hostinger-{{ .Version }}-checksums.sha256"
4141

4242
#dockers:
4343
# - dockerfile: Dockerfile.goreleaser
4444
# image_templates:
45-
# - "hostinger/hapi:latest"
46-
# - "hostinger/hapi:{{ .Major }}-latest"
47-
# - "hostinger/hapi:{{ .Version }}"
45+
# - "hostinger/hostinger:latest"
46+
# - "hostinger/hostinger:{{ .Major }}-latest"
47+
# - "hostinger/hostinger:{{ .Version }}"
4848

4949
release:
5050
github:
@@ -60,11 +60,11 @@ brews:
6060
description: "Hostinger API CLI"
6161
license: "MIT"
6262
install: |
63-
bin.install "hapi"
63+
bin.install "hostinger"
6464
extra_install: |
65-
bash_completion.install "completions/hapi.bash" => "hapi"
66-
zsh_completion.install "completions/hapi.zsh" => "_hapi"
67-
fish_completion.install "completions/hapi.fish"
65+
bash_completion.install "completions/hostinger.bash" => "hostinger"
66+
zsh_completion.install "completions/hostinger.zsh" => "_hostinger"
67+
fish_completion.install "completions/hostinger.fish"
6868
6969
changelog:
7070
disable: false

AUTOCOMPLETE.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enabling shell auto-completion
22

3-
`hapi` has auto-complete support. This makes it easier to use the CLI and improves user experience by completing command
4-
names by clicking TAB key. For example if you type `hapi vps dat<TAB>` with auto-completion enabled, shell will automatically append
5-
rest of the command: `hapi vps data-centers`.
3+
`hostinger` has auto-complete support. This makes it easier to use the CLI and improves user experience by completing command
4+
names by clicking TAB key. For example if you type `hostinger vps dat<TAB>` with auto-completion enabled, shell will automatically append
5+
rest of the command: `hostinger vps data-centers`.
66

77
Auto-completion can be generated for multiple shells. The currently supported shells are:
88
- Bash
@@ -15,11 +15,11 @@ After adding shell auto-completion, remember to refresh your shell profile by lo
1515
## Bash
1616
### Linux:
1717
```bash
18-
hapi completion bash > /etc/bash_completion.d/hapi
18+
hostinger completion bash > /etc/bash_completion.d/hostinger
1919
````
2020
### macOS:
2121
```bash
22-
myapp completion bash > /usr/local/etc/bash_completion.d/hapi
22+
hostinger completion bash > /usr/local/etc/bash_completion.d/hostinger
2323
```
2424

2525
## Zsh
@@ -30,25 +30,25 @@ echo "autoload -U compinit; compinit" >> ~/.zshrc
3030

3131
To load completions for each session, execute once:
3232
```bash
33-
hapi completion zsh > "${fpath[1]}/_hapi"
33+
hostinger completion zsh > "${fpath[1]}/_hostinger"
3434
```
3535
You will need to start a new shell for this setup to take effect.
3636

3737
## Fish
3838
```bash
39-
hapi completion fish | source
39+
hostinger completion fish | source
4040
```
4141
To load completions for each session, execute once:
4242
```bash
43-
hapi completion fish > ~/.config/fish/completions/hapi.fish
43+
hostinger completion fish > ~/.config/fish/completions/hostinger.fish
4444
```
4545

4646
## PowerShell
4747
```powershell
48-
hapi completion powershell | Out-String | Invoke-Expression
48+
hostinger completion powershell | Out-String | Invoke-Expression
4949
```
5050
To load completions for every new session, run:
5151
```powershell
52-
hapi completion powershell > hapi.ps1
52+
hostinger completion powershell > hostinger.ps1
5353
```
54-
and source this file from your PowerShell profile.
54+
and source this file from your PowerShell profile.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Hostinger API CLI
22

3-
`hapi` is the command line interface for the [Hostinger API](https://developers.hostinger.com).
3+
`hostinger` is the command line interface for the [Hostinger API](https://developers.hostinger.com).
44

55
> **This repository is generated.** Do not open pull requests here — every file
66
> is overwritten by the next generation run. The CLI is generated from the
@@ -13,10 +13,10 @@
1313
### Homebrew (macOS & Linux)
1414

1515
```sh
16-
brew install hostinger/tap/hapi
16+
brew install hostinger/tap/hostinger
1717
```
1818

19-
Upgrade with `brew upgrade hapi`. Shell tab-completion (bash/zsh/fish) is installed
19+
Upgrade with `brew upgrade hostinger`. Shell tab-completion (bash/zsh/fish) is installed
2020
automatically.
2121

2222
### Binary download
@@ -26,28 +26,28 @@ Download the binary for your platform from the
2626

2727
## Configuration
2828

29-
Create `$HOME/.hapi.yaml`:
29+
Create `$HOME/.hostinger.yaml`:
3030

3131
```yaml
3232
api_token: <your API token>
3333
```
3434
35-
or set the `HAPI_API_TOKEN` environment variable. Generate a token at
35+
or set the `HOSTINGER_API_TOKEN` environment variable. Generate a token at
3636
[hPanel → API](https://hpanel.hostinger.com/profile/api).
3737

3838
## Usage
3939

4040
```
41-
hapi <group> <subgroup> <verb> [args] [flags]
41+
hostinger <group> <subgroup> <verb> [args] [flags]
4242
```
4343
4444
Examples:
4545
4646
```
47-
hapi billing catalog list
48-
hapi vps virtual-machines list
49-
hapi vps vm start 123 # vm is an alias for virtual-machines
50-
hapi dns records list example.com
47+
hostinger billing catalog list
48+
hostinger vps virtual-machines list
49+
hostinger vps vm start 123 # vm is an alias for virtual-machines
50+
hostinger dns records list example.com
5151
```
5252
5353
Output format defaults to a table; use `--format json|table|tree` to change it.

cmd/root.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hostinger/api-cli/cmd/vps"
1313
"os"
1414

15+
"github.com/hostinger/api-cli/utils"
1516
"github.com/spf13/cobra"
1617
"github.com/spf13/viper"
1718
)
@@ -24,7 +25,7 @@ var (
2425
)
2526

2627
var RootCmd = &cobra.Command{
27-
Use: "hapi",
28+
Use: "hostinger",
2829
Short: "Hostinger API Command Line Interface",
2930
Long: ``,
3031
}
@@ -43,7 +44,7 @@ func init() {
4344

4445
RootCmd.DisableAutoGenTag = true
4546

46-
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Config file (default is $HOME/.hapi.yaml)")
47+
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Config file (default is $HOME/.hostinger.yaml)")
4748
RootCmd.PersistentFlags().StringVar(&OutputFormat, "format", "", "Output format type (json|table|tree), default: table")
4849

4950
RootCmd.RegisterFlagCompletionFunc("format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
@@ -68,13 +69,14 @@ func initConfig() {
6869
home, err := os.UserHomeDir()
6970
cobra.CheckErr(err)
7071

71-
viper.AddConfigPath(home)
72+
path, _ := utils.MigrateLegacyConfig(home, os.Stderr)
73+
viper.SetConfigFile(path)
7274
viper.SetConfigType("yaml")
73-
viper.SetConfigName(".hapi")
7475
}
7576

76-
viper.SetEnvPrefix("hapi")
77+
viper.SetEnvPrefix("hostinger")
7778
viper.AutomaticEnv() // read in environment variables that match
79+
utils.BindLegacyEnv(os.Stderr)
7880
if err := viper.ReadInConfig(); err == nil {
7981
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
8082
}

docs/hapi.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/hapi_billing.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/hapi_billing_catalog.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

docs/hapi_billing_payment-methods.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/hapi_billing_subscriptions.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/hapi_dns.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)