Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qba73 committed Jun 7, 2024
1 parent 869f31f commit 4143047
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 12 deletions.
87 changes: 86 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,88 @@
# mikrus

Go client library for [MIKRUS VPS](https://mikr.us) Provider
`mikrus` is a Go library and command-line client for the the [MIKRUS VPS](https://mikr.us) provider. It allows you to interact with provisioned servers and perform various tasks, for example:

- show information about your server
- list provisioned servers
- restart your server
- check last log messages
- boost your server performance by turning on Amfetamina functionality
- show config for your DB(s) (Postgres, MySQL)
- execute remote commands on your server
- show usage / resource utilization statistics
- show ports assigned to your server
- show cloud functions assigned to your account (including stats)
- add / change domain assigned to your server

## Installing the command-line client

To install the client binary, run:

```shell
go install github.com/qba73/mikrus/cmd/mikctl@latest
```

## Using the command-line client

To see help on using the client, run:

```shell
mikctl -h
```

## Setting your API key and Server ID

To use the client with your Mikrus account, you will need the API Key and Server ID provisioned in your Mikrus account. Go to the [Mikrus page](https://mikr.us/#pricing), sign up for the service. When your account is ready, go to the panel page and get your `server ID` and corresponding `API key`.

There are three ways to pass your API key to the client: in a config file, in an environment variable, or on the command line.

### In a config file

The `mikctl` client will read a config file named `.mikrus.yaml` (or `.mikrus.json`, or any other extension that Viper supports) in your home directory, or in the current directory.

For example, you can put your API key and sever ID in the file `$HOME/.mikrus.yaml`, and `mikctl` will find and read them automatically (replace `XXX` with your own API key, and `YYY` with your server ID):

```yaml
apiKey: XXX
srvID: YYY
```
### In an environment variable
`mikctl` will look for the API key and server ID in an environment variable named MIKRUS_API_KEY and MIKRUS_SRV_ID:

```shell
export MIKRUS_API_KEY=XXX
export MIKRUS_SRV_ID=YYY
mikctl ...
```

### On the command line

You can also pass your API key and server ID to the `mikctl` client using the `--apiKey` and `--srvID` flags like this:

```shell
mikctl --apiKey XXX --srvID YYY
```

## Testing your configuration

To test that your API key is correct and `mikctl` is reading it properly, run:

```shell
mikctl server
```

or

```shell
mikctl --srvID YYY --apiKey XXX server
```

## Bugs and feature requests

If you find a bug in the `mikrus` client or library, please [open an issue](https://github.com/qba73/mikrus/issues). Similarly, if you'd like a feature added or improved, let me know via an issue.

Not all the functionality of the [Mikrus API](https://api.mikr.us) is implemented yet.

Pull requests welcome!
19 changes: 8 additions & 11 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ func Execute() {
}

var (
apiKey string
srvID string
cfgFile string
client mikrus.Client
apiKey string
srvID string
client mikrus.Client
)

func init() {
viper.SetConfigName(".mikrus")
viper.SetConfigType("yaml")
viper.AddConfigPath("$HOME")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
Expand All @@ -52,13 +50,12 @@ func init() {
cobra.OnInitialize(func() {
client = mikrus.New(viper.GetString("apiKey"), viper.GetString("srvID"))
})

rootCmd.PersistentFlags().StringVar(&apiKey, "apiKey", "", "Mikrus server API key")
rootCmd.PersistentFlags().StringVar(&srvID, "srvID", "", "Mikrus server ID")
viper.BindPFlag("apiKey", rootCmd.PersistentFlags().Lookup("apiKey"))
viper.BindEnv("apiKey", "API_KEY")
viper.BindPFlag("srvID", rootCmd.PersistentFlags().Lookup("srvID"))
viper.BindEnv("apiKey", "SRV_ID")
viper.BindEnv("apiKey", "MIKRUS_API_KEY")

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.mikrus.yaml)")
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.PersistentFlags().StringVar(&srvID, "srvID", "", "Mikrus server ID")
viper.BindPFlag("srvID", rootCmd.PersistentFlags().Lookup("srvID"))
viper.BindEnv("apiKey", "MIKRUS_SRV_ID")
}

0 comments on commit 4143047

Please sign in to comment.