gh issue コマンド

gh issueコマンドは、issueの作成や閲覧することができます。

gh issue <command> [flags]で実行し、<command>には以下の6個が利用できます。

close:      Close issue
create:     Create a new issue
list:       List and filter issues in this repository
reopen:     Reopen issue
status:     Show status of relevant issues
view:       View an issue

gh issue create

gh issue createコマンドは、issueを作成することができるコマンドです。

gh issue create [flags]で実行する。

フラグ

以下のフラグが利用できます。

flags short flags long 説明
-a --assignee assigneeを指定
-b --body bodyを指定
-l --label ラベルを指定
-m --milestone マイルストーンを指定
-p --project プロジェクトを指定
-t --title タイトルを指定
-w --web ブラウザで開く

対話形式でissueを作成

まずはタイトルを指定します。

$ gh issue create

Creating issue in JIIOryo/foo

? Title hoge bug 🐛

eを押すことで、エディタが開きます。

? Body [(e) to launch vim, enter to skip]

入力が完了。

? Body <Received>
? What's next?  [Use arrows to move, type to filter]
> Submit
  Continue in browser
  Add metadata
  Cancel

Add metadataで、assigneeやlabelを指定することができます。移動は上下ボタン、選択はスペースキーです。確定はEnter。

? What would you like to add?  [Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
  [ ]  Assignees
> [x]  Labels
  [ ]  Projects
  [ ]  Milestone

Labelを選択すると、以下のようにラベル一覧が表示されます。同様に移動は上下ボタン、選択はスペースキーです。確定はEnter。

? Labels  [Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
  [x]  bug
  [ ]  documentation
  [ ]  duplicate
> [ ]  enhancement
  [x]  fuga
  [ ]  good first issue
  [ ]  help wanted

Submitしましょう。

? What's next?  [Use arrows to move, type to filter]
> Submit
  Cancel
https://github.com/JIIOryo/foo/issues/11

issueができたみたいなので、みてみます。

スクリーンショット 2020-09-20 13.41.02.png

コマンドで一発でissueを作成する。

-tでタイトル、-bでbody、-lでラベル、-mでマイルストーンを選択してみました。

$ gh issue create -t 'fuga bug 🐛' -b 'fugafuga' -l hoge,fuga -m foo

Creating issue in JIIOryo/foo

https://github.com/JIIOryo/foo/issues/12

ちなみに、-wオプションをつけるとissueを作成する画面がブラウザで開きます。

help

$ gh issue create --help
Create a new issue

USAGE
  gh issue create [flags]

FLAGS
  -a, --assignee login   Assign people by their login
  -b, --body string      Supply a body. Will prompt for one otherwise.
  -l, --label name       Add labels by name
  -m, --milestone name   Add the issue to a milestone by name
  -p, --project name     Add the issue to projects by name
  -t, --title string     Supply a title. Will prompt for one otherwise.
  -w, --web              Open the browser to create an issue

INHERITED FLAGS
      --help              Show help for command
  -R, --repo OWNER/REPO   Select another repository using the OWNER/REPO format

EXAMPLES
  $ gh issue create --title "I found a bug" --body "Nothing works"
  $ gh issue create --label "bug,help wanted"
  $ gh issue create --label bug --label "help wanted"
  $ gh issue create --assignee monalisa,hubot
  $ gh issue create --project "Roadmap"

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

gh issue list

gh issue listコマンドは、issueの一覧を表示することができます。

gh issue list [flags]で実行する。

フラグ

以下のフラグが利用できます。

flags short flags long 説明
-a --assignee assigneeでフィルタリング
-A --author authorでフィルタリング
-l --label ラベルでフィルタリング
-L --limit issueの最大表示件数を指定 (デフォルト30件)
-m --milestone マイルストーンをでフィルタリング
  --mention メンションでフィルタリング
-p --project プロジェクトを指定
-s --state 状態でフィルタリング open,closed,allが指定できます。(デフォルトopen
-w --web ブラウザで開く

$ gh issue list

Showing 2 of 2 open issues in JIIOryo/foo

#12  fuga bug 🐛  (fuga, hoge)       about 5 minutes ago
#11  hoge bug 🐛  (bug, fuga, hoge)  about 9 minutes ago

フラグを付けて検索してみます。

$ gh issue list -l hoge,fuga -L 1 -s all

Showing 1 of 2 issues in JIIOryo/foo that match your search

#12  fuga bug 🐛  (fuga, hoge)  about 10 minutes ago

help

$ gh issue list --help
List and filter issues in this repository

USAGE
  gh issue list [flags]

FLAGS
  -a, --assignee string    Filter by assignee
  -A, --author string      Filter by author
  -l, --label strings      Filter by labels
  -L, --limit int          Maximum number of issues to fetch (default 30)
      --mention string     Filter by mention
  -m, --milestone number   Filter by milestone number or `title`
  -s, --state string       Filter by state: {open|closed|all} (default "open")
  -w, --web                Open the browser to list the issue(s)

INHERITED FLAGS
      --help              Show help for command
  -R, --repo OWNER/REPO   Select another repository using the OWNER/REPO format

EXAMPLES
  $ gh issue list -l "help wanted"
  $ gh issue list -A monalisa
  $ gh issue list --web
  $ gh issue list --milestone 'MVP'

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

gh issue status

gh issue statusコマンドは、issueのステータスを表示するコマンドです。

gh issue status [flags]で実行する。 自分がアサインされたissue, メンションされたissue, 自分が作成したissueを確認することができます。

$ gh issue status

Relevant issues in JIIOryo/foo

Issues assigned to you
  #12  fuga bug 🐛  (fuga, hoge)  less than a minute ago

Issues mentioning you
  #12  fuga bug 🐛  (fuga, hoge)  less than a minute ago

Issues opened by you
  #12  fuga bug 🐛  (fuga, hoge)       less than a minute ago
  #11  hoge bug 🐛  (bug, fuga, hoge)  about 3 hours ago

help

$ gh issue status --help
Show status of relevant issues

USAGE
  gh issue status [flags]

INHERITED FLAGS
      --help              Show help for command
  -R, --repo OWNER/REPO   Select another repository using the OWNER/REPO format

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

gh issue close

gh issue closeコマンドは、issueをcloseすることができるコマンドです。

gh issue close {<number> | <url>} [flags]で実行する。 issueを選択する方法は、issue番号, issueのURLの2つがあります。

$ gh issue close 12
✔ Closed issue #12 (fuga bug 🐛)
$ gh issue close https://github.com/JIIOryo/foo/issues/12
✔ Closed issue #12 (fuga bug 🐛)

help

$ gh issue close --help
Close issue

USAGE
  gh issue close {<number> | <url>} [flags]

INHERITED FLAGS
      --help              Show help for command
  -R, --repo OWNER/REPO   Select another repository using the OWNER/REPO format

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

gh issue reopen

gh issue reopenコマンドは、closeしたissueを再び開くコマンドです。

gh issue reopen {<number> | <url>} [flags]で実行します。 issueを選択する方法は、issue番号, issueのURLの2つがあります。

$ gh issue reopen 12
✔ Reopened issue #12 (fuga bug 🐛)
$ gh issue reopen https://github.com/JIIOryo/foo/issues/12
✔ Reopened issue #12 (fuga bug 🐛)

help

$ gh issue reopen --help
Reopen issue

USAGE
  gh issue reopen {<number> | <url>} [flags]

INHERITED FLAGS
      --help              Show help for command
  -R, --repo OWNER/REPO   Select another repository using the OWNER/REPO format

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

gh issue view

gh issue viewコマンドは、issueを閲覧することができるコマンドです。

gh issue view {<number> | <url>} [flags]で実行する。 issueを選択する方法は、issue番号, issueのURLの2つがあります。

フラグ

以下のフラグが利用できます。

flags short flags long 説明
-w --web ブラウザで開く

$ gh issue view 11
$ gh issue view https://github.com/JIIOryo/foo/issues/11

スクリーンショット 2020-09-20 17.31.58.png

markdownがしっかり認識されて色付けされていてみやすいですが、ブラウザでしっかり確認したい場合もあります。

そのような場合は-wオプションを利用します。

$ gh issue view 11 -w
Opening github.com/JIIOryo/foo/issues/11 in your browser.

スクリーンショット 2020-09-20 17.34.34.png

help

$ gh issue view --help
Display the title, body, and other information about an issue.

With '--web', open the issue in a web browser instead.


USAGE
  gh issue view {<number> | <url>} [flags]

FLAGS
  -w, --web   Open an issue in the browser

INHERITED FLAGS
      --help              Show help for command
  -R, --repo OWNER/REPO   Select another repository using the OWNER/REPO format

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual