An open API service indexing awesome lists of open source software.

https://github.com/ebonsignori/gh-search-docs

A `gh` CLI extension for searching GitHub Docs from your terminal.
https://github.com/ebonsignori/gh-search-docs

cli gh-extension search

Last synced: 10 months ago
JSON representation

A `gh` CLI extension for searching GitHub Docs from your terminal.

Awesome Lists containing this project

README

          

# Search (GitHub) Docs CLI

[![Test and Lint](https://github.com/Ebonsignori/gh-search-docs/actions/workflows/test-and-lint.yml/badge.svg)](https://github.com/Ebonsignori/gh-search-docs/actions/workflows/test-and-lint.yml)

A [CLI Extension](https://docs.github.com/en/github-cli/github-cli/using-github-cli-extensions) for the [GitHub CLI](https://cli.github.com/) that lets you search the GitHub documentation using the official GitHub documentation search API.

Search results are returned from the search API provided by [docs.github.com](https://docs.github.com/en).

![Demonstration of using `gh search-docs` to ask "ssh key" and getting 5 results.](./docs/demo.png)

## Installation

Install this extension using the GitHub CLI:

```bash
gh extension install ebonsignori/gh-search-docs
```

### Prerequisites

You'll need the [GitHub CLI](https://cli.github.com/) installed first:
- macOS: `brew install gh`
- Windows: `winget install GitHub.cli`
- Linux: See [installation instructions](https://github.com/cli/cli#installation)

## Usage

```bash
gh search-docs [flags]
```

### Examples

Search for documentation:
```bash
gh search-docs "pull request"
```

Search with specific parameters:
```bash
gh search-docs --size 5 --highlights title,content "GitHub Actions"
```

Search Enterprise Server documentation:
```bash
gh search-docs --version enterprise-server@3.17 "SAML configuration"
```

Get results in plain text format:
```bash
gh search-docs --plain "API authentication"
```

Get results in JSON format:
```bash
gh search-docs --format json "API authentication"
```

Search with additional includes:
```bash
gh search-docs --include intro,headings "webhook events"
```

Paginate through results:
```bash
gh search-docs --page 2 --size 20 "Git workflow"
```

## Flags

| Flag | Description |
|------|-------------|
| `--query` | Search query (can also be provided as positional argument) |
| `--size` | Number of results to return (max: 50, default: 5) |
| `--version` | Docs version (`free-pro-team`, `enterprise-cloud`, or `enterprise-server@<3.13-3.17>`) |
| `--language` | Language code (default: en) |
| `--page` | Page number for pagination |
| `--sort` | Sort order |
| `--highlights` | Highlight options (can be used multiple times): `title`, `content`, `content_explicit`, `term` |
| `--include` | Additional includes (can be used multiple times): `intro`, `headings`, `toplevel` |
| `--toplevel` | Toplevel filter (can be used multiple times) |
| `--aggregate` | Aggregate options (can be used multiple times) |
| `--debug` | Show raw JSON response from the API |
| `--format` | Output format: `pretty` (default), `plain`, `json` |
| `--plain` | Disable pretty rendering (use plain text output) |
| `--list-versions` | List supported GitHub Enterprise Server versions |

## More examples

### Finding specific topics:
```bash
gh search-docs "repository settings"
gh search-docs "branch protection rules"
gh search-docs "GitHub Apps authentication"
```

### Enterprise-specific searches:
```bash
gh search-docs --version enterprise-server@3.17 "LDAP configuration"
gh search-docs --version enterprise-cloud "SAML SSO"
```

### Detailed searches with highlights:
```bash
gh search-docs --highlights title,content --include intro,headings "webhook payload"
```

### Paginated browsing:
```bash
gh search-docs --size 5 "API" --page 1
gh search-docs --size 5 "API" --page 2
```

## Development

Please see [development docs](./DEVELOPMENT.md).

## License

MIT