Skip to content

Commit 2b4010c

Browse files
committed
chore: documentation updates
1 parent afc60db commit 2b4010c

File tree

70 files changed

+2071
-4
lines changed

Some content is hidden

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

70 files changed

+2071
-4
lines changed

.goreleaser.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
project_name: hapi
22
version: 2
3+
builds:
4+
- main: ./main.go
5+
env:
6+
- CGO_ENABLED=0
7+
- GO111MODULE=on
8+
flags:
9+
- -mod=vendor
10+
- -v
11+
goos:
12+
- windows
13+
- darwin
14+
- linux
15+
316
archives:
417
- name_template: "hapi-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
518
format_overrides:

AUTOCOMPLETE.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Enabling shell auto-completion
2+
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`.
6+
7+
Auto-completion can be generated for multiple shells. The currently supported shells are:
8+
- Bash
9+
- Zsh
10+
- fish
11+
- PowerShell
12+
13+
After adding shell auto-completion, remember to refresh your shell profile by logging out from the shell and log back in.
14+
15+
## Bash
16+
### Linux:
17+
```bash
18+
hapi completion bash > /etc/bash_completion.d/hapi
19+
````
20+
### macOS:
21+
```bash
22+
myapp completion bash > /usr/local/etc/bash_completion.d/hapi
23+
```
24+
25+
## Zsh
26+
If shell completion is not already enabled in your environment, you will need to enable it. You can execute the following once:
27+
```bash
28+
echo "autoload -U compinit; compinit" >> ~/.zshrc
29+
```
30+
31+
To load completions for each session, execute once:
32+
```bash
33+
hapi completion zsh > "${fpath[1]}/_hapi"
34+
```
35+
You will need to start a new shell for this setup to take effect.
36+
37+
## Fish
38+
```bash
39+
hapi completion fish | source
40+
```
41+
To load completions for each session, execute once:
42+
```bash
43+
hapi completion fish > ~/.config/fish/completions/hapi.fish
44+
```
45+
46+
## PowerShell
47+
```powershell
48+
hapi completion powershell | Out-String | Invoke-Expression
49+
```
50+
To load completions for every new session, run:
51+
```powershell
52+
hapi completion powershell > hapi.ps1
53+
```
54+
and source this file from your PowerShell profile.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Hostinger API Command Line Interface
2+
3+
A powerful command-line interface for managing Hostinger services through the Hostinger API.
4+
5+
For more information, please visit https://developers.hostinger.com.
6+
7+
# Installation
8+
9+
## Downloading a Release from GitHub
10+
Download the latest binary from the [releases page](https://github.com/hostinger/api-cli/releases).
11+
12+
### Linux
13+
14+
Download, extract and move the binary:
15+
```bash
16+
cd ~
17+
wget https://github.com/hostinger/api-cli/releases/download/<version>/hapi-<version>-linux-<arch>.tar.gz
18+
tar xf ~/hapi-<version>-linux-<arch>.tar.gz
19+
mv hapi /usr/local/bin
20+
```
21+
22+
### macOS
23+
WIP
24+
25+
### Windows
26+
WIP
27+
28+
# Configuration
29+
30+
## File
31+
Full example and possible values of the configuration file [can be found here](https://github.com/hostinger/api-cli/blob/main/hapi.yaml)
32+
33+
By default, configuration file will be read from `$HOME/.hapi.yaml`.
34+
35+
You can always define which configuration file to use by using `--config` argument, eg.:
36+
```bash
37+
hapi --config path/to/your/config.yaml ...
38+
```
39+
40+
## Environment variables
41+
Instead of providing configuration file, you can provide configuration using environment variables.
42+
Each config file property must have `HAPI_` prefix and key name in ALL CAPS, for example to provide
43+
`api_token` parameter, you would export variable like this:
44+
45+
```bash
46+
export HAPI_API_TOKEN=<your token>
47+
hapi vps vm list
48+
```
49+
50+
# Usage
51+
52+
See the [full reference documentation](blob/main/docs/hapi.md) for information about each available command.
53+
54+
# Enabling shell auto-completion (optional)
55+
56+
`hapi` has auto-complete support. This makes it easier to use the CLI and improves user experience by completing command
57+
names by clicking TAB key. For example if you type `hapi vps dat<TAB>` with auto-completion enabled, shell will automatically append
58+
rest of the command: `hapi vps data-centers`.
59+
60+
Auto-completion can be generated for multiple shells. The currently supported shells are:
61+
- Bash
62+
- Zsh
63+
- fish
64+
- PowerShell
65+
66+
After adding shell auto-completion, remember to refresh your shell profile by logging out from the shell and log back in.
67+
68+
Read more on [how to enable auto-completion](blob/main/AUTOCOMPLETE.md).

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func initConfig() {
5858
viper.SetConfigName(".hapi")
5959
}
6060

61+
viper.SetEnvPrefix("hapi")
6162
viper.AutomaticEnv() // read in environment variables that match
6263
if err := viper.ReadInConfig(); err == nil {
6364
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())

docs/hapi.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## hapi
2+
3+
Hostinger API Command Line Interface
4+
5+
### Options
6+
7+
```
8+
--config string Config file (default is $HOME/.hapi.yaml)
9+
--format string Output format type (json|table|tree), default: table
10+
-h, --help help for hapi
11+
```
12+
13+
### SEE ALSO
14+
15+
* [hapi vps](hapi_vps.md) - VPS management
16+

docs/hapi_vps.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## hapi vps
2+
3+
VPS management
4+
5+
### Options
6+
7+
```
8+
-h, --help help for vps
9+
```
10+
11+
### Options inherited from parent commands
12+
13+
```
14+
--config string Config file (default is $HOME/.hapi.yaml)
15+
--format string Output format type (json|table|tree), default: table
16+
```
17+
18+
### SEE ALSO
19+
20+
* [hapi](hapi.md) - Hostinger API Command Line Interface
21+
* [hapi vps actions](hapi_vps_actions.md) - VM actions information
22+
* [hapi vps backups](hapi_vps_backups.md) - VM backup management
23+
* [hapi vps data-centers](hapi_vps_data-centers.md) - Data center information
24+
* [hapi vps firewall](hapi_vps_firewall.md) - Firewall management
25+
* [hapi vps monarx](hapi_vps_monarx.md) - Malware scanner
26+
* [hapi vps post-install-scripts](hapi_vps_post-install-scripts.md) - Post-install script management
27+
* [hapi vps ptr](hapi_vps_ptr.md) - PTR records management
28+
* [hapi vps public-keys](hapi_vps_public-keys.md) - Public key management
29+
* [hapi vps recovery](hapi_vps_recovery.md) - Recovery mode management
30+
* [hapi vps snapshots](hapi_vps_snapshots.md) - Snapshot management
31+
* [hapi vps templates](hapi_vps_templates.md) - OS Templates
32+
* [hapi vps vm](hapi_vps_vm.md) - A brief description of your command
33+

docs/hapi_vps_actions.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## hapi vps actions
2+
3+
VM actions information
4+
5+
### Synopsis
6+
7+
Track and review operations performed on your virtual machines. These endpoints provide details about specific actions—such as start, stop, or restart—including timestamps and statuses.
8+
9+
### Options
10+
11+
```
12+
-h, --help help for actions
13+
```
14+
15+
### Options inherited from parent commands
16+
17+
```
18+
--config string Config file (default is $HOME/.hapi.yaml)
19+
--format string Output format type (json|table|tree), default: table
20+
```
21+
22+
### SEE ALSO
23+
24+
* [hapi vps](hapi_vps.md) - VPS management
25+
* [hapi vps actions get](hapi_vps_actions_get.md) - Get action
26+
* [hapi vps actions list](hapi_vps_actions_list.md) - Get action list
27+

docs/hapi_vps_actions_get.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## hapi vps actions get
2+
3+
Get action
4+
5+
### Synopsis
6+
7+
This endpoint retrieves details of a specific action performed on a specified virtual machine.
8+
This endpoint allows you to view detailed information about a particular action, including the action name, timestamp, and status.
9+
10+
```
11+
hapi vps actions get <virtual machine ID> <action ID> [flags]
12+
```
13+
14+
### Options
15+
16+
```
17+
-h, --help help for get
18+
```
19+
20+
### Options inherited from parent commands
21+
22+
```
23+
--config string Config file (default is $HOME/.hapi.yaml)
24+
--format string Output format type (json|table|tree), default: table
25+
```
26+
27+
### SEE ALSO
28+
29+
* [hapi vps actions](hapi_vps_actions.md) - VM actions information
30+

docs/hapi_vps_actions_list.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## hapi vps actions list
2+
3+
Get action list
4+
5+
### Synopsis
6+
7+
Actions are operations or events that have been executed on the virtual machine, such as starting, stopping,
8+
or modifying the machine. This endpoint allows you to view the history of these actions, providing details about each
9+
action, such as the action name, timestamp, and status.
10+
11+
```
12+
hapi vps actions list <virtual machine ID> [flags]
13+
```
14+
15+
### Options
16+
17+
```
18+
-h, --help help for list
19+
--page int Page number (default 1)
20+
```
21+
22+
### Options inherited from parent commands
23+
24+
```
25+
--config string Config file (default is $HOME/.hapi.yaml)
26+
--format string Output format type (json|table|tree), default: table
27+
```
28+
29+
### SEE ALSO
30+
31+
* [hapi vps actions](hapi_vps_actions.md) - VM actions information
32+

docs/hapi_vps_backups.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## hapi vps backups
2+
3+
VM backup management
4+
5+
### Synopsis
6+
7+
Safeguard your data by managing backups. You can list available backups, restore a virtual machine from a backup, or delete backups as needed.
8+
9+
### Options
10+
11+
```
12+
-h, --help help for backups
13+
```
14+
15+
### Options inherited from parent commands
16+
17+
```
18+
--config string Config file (default is $HOME/.hapi.yaml)
19+
--format string Output format type (json|table|tree), default: table
20+
```
21+
22+
### SEE ALSO
23+
24+
* [hapi vps](hapi_vps.md) - VPS management
25+
* [hapi vps backups delete](hapi_vps_backups_delete.md) - Delete backup
26+
* [hapi vps backups list](hapi_vps_backups_list.md) - Get backup list
27+
* [hapi vps backups restore](hapi_vps_backups_restore.md) - Restore backup
28+

0 commit comments

Comments
 (0)