Skip to content

Commit

Permalink
docs: improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
beliven-fabrizio-gortani committed Jun 22, 2023
1 parent f2cffdf commit 05d4ac6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

A CLI to easily list, search and connect to SSH hosts. Sync down hosts from providers in order to get a centralized hosts configuration.

<br><br><br><br>

## Install

Add Homebrew Beliven tap with:
Expand All @@ -28,6 +30,8 @@ Then install `hssh` CLI with:
brew install hssh
```

<br><br><br><br>

## Configuration

Run `hssh init` to generate config file inside `~/.config/hssh/config.yml` (works only if not exists yet) or let the CLI creating it automatically on first run (every command).
Expand All @@ -37,6 +41,8 @@ Right now the CLI supports the following providers:
- GitLab
- GitHub

<br><br>

### Providers

Provide at least one connection string to a provider to start using the CLI. You can use more providers at the same time. Replace values as reported below.
Expand All @@ -51,10 +57,35 @@ Provide at least one connection string to a provider to start using the CLI. You
- **ENTITY_ID** is the reference to the project/repository where the files are stored. For GitLab is the project ID, you can find it under the project name (eg. `7192789`). For GitHub is the name of the repository (eg. `beliven-it/hssh`).
- **SUBPATH** is the path to the folder inside the project/repository where config files are saved. This parameter is optional, if you want to store hosts files inside the root of the project/repository, you can delete the `@` and everything after it in the connection string.

You can also provide a structured version of the provider configuration in the following format:

```yml
providers:
- type: gitlab
url: "https://gitlab.com/api/v4"
access_token: gpat-123456789
entity_id: 9999
subpath: "path/to/folder"
- type: gitlab
url: "https://git.my-domain.com/api/v4"
access_token: mydingpat-123444444
entity_id: 11
subpath: "path"

```

> **NOTE**
>
> You cannot have the two providers configuration in different format. Make sure to use or the structured version, or the string version.
<br><br>

### fzf options

See the man page (`man fzf`) for the full list of available options and add the desired ones to the `fzf_options` string inside `~/.config/hssh/config.yml`. See more about the fzf options in the [official repository](https://github.com/junegunn/fzf#options).

<br><br>

### Config file example

This is a complete config file example with two providers:
Expand Down Expand Up @@ -96,10 +127,14 @@ SSH host example to put inside hosts files:
IdentityFile ~/ssh/id_rsa
```

<br><br><br><br>

## Usage

To see available commands and options, run: `hssh`, `hssh help`, `hssh --help` or `hssh -h`.

<br><br><br><br>

## Development

Clone the repository and run inside the folder:
Expand All @@ -110,14 +145,19 @@ Clone the repository and run inside the folder:

Run `./hssh` inside the folder to test the CLI.

<br><br><br><br>

## Have found a bug?

Please open a new issue [here](https://github.com/beliven-it/hssh/issues).

<br><br><br><br>
## Mentions

- [dmitri13](https://www.flaticon.com/authors/dmitri13) for the icon of the terminal used in the banner image

<br><br><br><br>

## License

Licensed under [MIT](./LICENSE)
2 changes: 1 addition & 1 deletion providers/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type IProvider interface {
type ProviderConnection struct {
Type string `mapstructure:"type"`
URL string `mapstructure:"url"`
Token string `mapstructure:"token"`
Token string `mapstructure:"access_token"`
EntityID string `mapstructure:"entity_id"`
Subpath string `mapstructure:"subpath"`
}
Expand Down
4 changes: 2 additions & 2 deletions templates/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ fzf_options: "-i"
providers:
- type: gitlab
url: "https://gitlab.com/api/v4"
token: "<MY-TOKEN>"
access_token: "<MY-TOKEN>"
entity_id: "<ENTITY_ID>"
subpath: "<SUBPATH>"
- type: github
url: "https://api.github.com"
token: "<MY-TOKEN>"
access_token: "<MY-TOKEN>"
entity_id: "<ENTITY_ID>"
subpath: "<SUBPATH>"
`

0 comments on commit 05d4ac6

Please sign in to comment.