ghs

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ghs — GitHub Select

CI Release Go Report Card

ghs は 「ghq のインタラクティブ拡張版」 を目指した Go 製 CLI ツールです。 自分や所属組織の GitHub リポジトリをターミナル UI で検索・選択し、 ghq 準拠のディレクトリ構成 ($base/github.com/Owner/Repo) にクローンします。

✨ 特徴

  • 🔑 GitHub CLI (gh auth token) の認証情報をそのまま流用
  • 🏢 自分のアカウントと所属組織を選択して切り替え
  • 🔍 survey.Select のインクリメンタルフィルタでリポジトリを高速検索
  • 📦 ghq 互換のディレクトリレイアウトでクローン
  • ⚙️ ~/.config/ghs/config.toml でベースディレクトリ等を設定可能

📥 インストール

Homebrew (macOS / Linux)
brew install ray-on-code/tap/ghs
GitHub Releases (バイナリ直接)

Releases ページ から お使いの OS / アーキテクチャ向けのアーカイブをダウンロードし、 解凍した ghs バイナリを PATH の通った場所に配置してください。

# 例: macOS arm64
curl -L https://github.com/ray-on-code/ghs/releases/latest/download/ghs_Darwin_arm64.tar.gz \
  | tar -xz -C /usr/local/bin ghs
Go Install
go install github.com/ray-on-code/ghs@latest
ソースからビルド
git clone https://github.com/ray-on-code/ghs.git
cd ghs
make build   # bin/ghs に生成される

🚀 使い方

# 起動するだけで対話的に Owner → リポジトリ を選択 → クローンします
ghs

# SSH URL でクローンしたい場合
ghs --ssh

# ベースディレクトリを一時的に上書き
ghs --base-dir ~/work/ghs
サブコマンド
コマンド 説明
ghs config init ~/.config/ghs/config.toml のテンプレートを生成
ghs config path 設定ファイルのフルパスを表示
ghs version バージョン情報を表示

🔐 認証

トークンは以下の優先順位で解決されます。

  1. gh auth token — GitHub CLI が認証済みであればそれを使用 (推奨)
  2. ~/.config/ghs/config.toml — 下記の github_token キー
# ~/.config/ghs/config.toml
github_token = "ghp_xxxxxxxxxxxxxxxxxxxx"
clone_base_dir = "~/ghs"

💡 GitHub CLI を使うのが最も簡単です。brew install gh && gh auth login を実行してください。

環境変数によるオーバーライド

GHS_ プレフィックス付きの環境変数でも設定を上書きできます。

export GHS_CLONE_BASE_DIR="$HOME/work/ghs"

🗂 ディレクトリ構成

.
├── cmd/                # Cobra コマンド定義
│   ├── root.go
│   ├── config.go
│   └── version.go
├── pkg/
│   ├── auth/           # GitHub トークン解決ロジック
│   ├── config/         # Viper を用いた設定ロード/生成
│   ├── github/         # google/go-github の薄いラッパー
│   ├── ui/             # survey/v2 を用いた TUI
│   └── cloner/         # ghq 準拠のパス決定 + `git clone` 実行
└── main.go

🛠 動作要件

  • Go 1.22 以上 (go.mod を参照)
  • git コマンド
  • (推奨) GitHub CLI (gh)

🧰 開発

開発に必要なタスクは Makefile に集約されています。

make            # ヘルプ表示
make build      # bin/ghs にビルド (VERSION 注入付き)
make test       # 全テスト実行
make test-race  # race detector 付きでテスト
make cover      # カバレッジ計測
make cover-html # coverage.html を生成
make fmt        # gofmt 適用
make vet        # go vet
make tidy       # go mod tidy
make check      # fmt-check + vet + test (PR 前推奨)
make ci         # CI 用一式 (fmt-check + vet + test-race + cover)
make clean      # 成果物削除

リント (golangci-lint) を使うには make tools でインストールしてから make lint を実行してください。

コントリビューション

ブランチ運用・コミット規約は CONTRIBUTING.md を参照してください。 リリース手順は RELEASING.md を参照してください。

📜 ライセンス

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd は ghs の Cobra コマンド定義を集約します。
Package cmd は ghs の Cobra コマンド定義を集約します。
pkg
auth
Package auth は GitHub のアクセストークンを解決するロジックを提供します。
Package auth は GitHub のアクセストークンを解決するロジックを提供します。
cloner
Package cloner はリポジトリのクローン先パス決定と `git clone` の実行を担当します。
Package cloner はリポジトリのクローン先パス決定と `git clone` の実行を担当します。
config
Package config はアプリケーションの設定ファイル管理を担当します。
Package config はアプリケーションの設定ファイル管理を担当します。
github
Package github は go-github を薄くラップし、ghs から必要な操作のみを公開します。
Package github は go-github を薄くラップし、ghs から必要な操作のみを公開します。
ui
Package ui はターミナル UI (TUI) のプロンプト処理を担当します。
Package ui はターミナル UI (TUI) のプロンプト処理を担当します。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL