GiitHub CLI 1.0이 출시되었기 때문에
                                            
                                                
                                                
                                                
                                                
                                                
                                                 15580 단어  ghGitHub CLItech
                    
gh 명령을 통해 Zenn과 연합한 창고를 조작해 명령의 사용감을 확인하고 동시에 Zenn에 투고한 것이다.Zenn에서 기사를 작성하는 방법에 대해서는 다음 기사를 참조하십시오.
gh의 설치
Mac의 경우 Homebrew 또는 MacPorts에서 설치 가능:
$ brew install gh
$ sudo port install gh
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
$ sudo apt-add-repository -u https://cli.github.com/packages
$ sudo apt install gh
명령 완성
gh 명령의 보완을 사용하기 위해 케이스의 프로필에 보충합니다.예를 들어, 하우징이 bash인 경우 gh에 다음 행을 추가합니다.eval "$(gh completion -s bash)"
.bash_profile 후 Tab 키를 누르면 다음 후보 하위 명령이 표시됩니다.$ gh
alias       -- Create command shortcuts
api         -- Make an authenticated GitHub API request
auth        -- Login, logout, and refresh your authentication
completion  -- Generate shell completion scripts
config      -- Manage configuration for gh
gist        -- Create gists
help        -- Help about any command
issue       -- Manage issues
pr          -- Manage pull requests
release     -- Manage GitHub releases
repo        -- Create, clone, fork, and view repositories
인증
gh  명령에서 GiitHub의 자원을 조작할 수 있도록 인증용 명령을 실행해야 한다.인증 프로세스는 다음 명령으로 시작됩니다.$ gh auth login
gh 명령을 통해 인증 상태를 확인할 수 있습니다.$ gh auth status 
github.com
  ✓ Logged in to github.com as morinokami (~/.config/gh/hosts.yml)
  ✓ Git operations for github.com configured to use ssh protocol.
gh auth status 명령을 사용할 준비가 되어 있습니다.지금부터 젠과 합작한 창고를 제작하고 조작해 보자.창고 만들기
우선 창고를 만들자.
gh는 Docker의 CLI와 마찬가지로 하위 명령으로 작업 객체의 리소스를 지정하고 작업 내용을 기술하는 스타일입니다.gh 하위 명령을 통해 창고를 조작합니다.repo에 대한 작업은 다음과 같습니다.$ gh repo
clone   -- Clone a repository locally
create  -- Create a new repository
fork    -- Create a fork of a repository
view    -- View a repository
repo를 사용하여 창고를 만듭니다.create의 사용 방법을 조사하기 위해 집행create 후 반년 동안gh repo create --help 이 항목을 발견할 수 있다.여기서 EXAMPLES라는 명령을 실행하면 자신의 계정과 관련된 명령을 만들 수 있다gh repo create my-repo.그 밖에 my-repo로고를 통해 대중에게 창고를 설치할 수 있다.우리 서둘러 집행합시다.$ gh repo create --public zenn-docs                                                                                                                                                                                                       
? This will create 'zenn-docs' in your current directory. Continue?  Yes
✓ Created repository morinokami/zenn-docs on GitHub
? Create a local project directory for morinokami/zenn-docs? Yes
Initialized empty Git repository in /home/shf0811/dev/zenn-docs/.git/
✓ Initialized repository in './zenn-docs/'
다음 명령을 사용하여 창고가 작성되었음을 확인할 수도 있습니다.
$ cd zenn-docs
$ gh repo view 
morinokami/zenn-docs
No description provided
This repository does not have a README
View this repository on GitHub: https://github.com/morinokami/zenn-docs
--public 깃발을 사용하여 브라우저에서도 확인할 수 있습니다.이때 Zenn과 합작할 수 있기 때문에 아래 명령을 사용하여 창고를 초기화한 다음에 Zenn의Deploys부터 합작 창고를 시작합니다.
echo "# zenn-docs" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin [email protected]:morinokami/zenn-docs.git
git push -u origin master
태엽 생성
다음은 차슈를 만들어 보세요.지게소와 관련된 조작에 대응하는 것은
--web이다.이에 대해 나도 가능한 조작을 확인해 보겠다.$ gh issue
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였다.다른 라벨과 assin 목적지도 지정할 수 있을 것 같으니 이번에는 간단하게 가보자.$ gh issue create --title "Add an article" --body "This issue was created by gh."       
Creating issue in morinokami/zenn-docs
https://github.com/morinokami/zenn-docs/issues/1
gh issue create --title "I found a bug" --body "Nothing works":$ gh issue status
Relevant issues in morinokami/zenn-docs
Issues assigned to you
  There are no issues assigned to you
Issues mentioning you
  There are no issues mentioning you
Issues opened by you
  #1  Add an article    about 1 hour ago
status 명령을 사용하십시오.개별 문제에 대한 자세한 내용을 확인하려면
list 명령을 사용하십시오.예를 들어, 방금 만든 차슈를 확인하기 위해 차슈 번호가 1이므로 다음 명령을 수행합니다.$ gh issue view 1
Add an article
Open • morinokami opened less than a minute ago • 0 comments
  This issue was created by gh.                                               
View this issue on GitHub: https://github.com/morinokami/zenn-docs/issues/1
초대 요청 작성
먼저 새로운 분기를 만들고 그 중에서 글을 쓴다.
$ git switch -c first-article
$ mkdir articles
$ vim articles/hello-github-cli.md
$ npx zenn new:article
npx: installed 9 in 1.424s
command not found: zenn
zsh: exit 1     npx zenn new:article
view입니다.다음 예제에서 가능한 작업을 나열합니다.$ gh pr
checkout  -- Check out a pull request in git
checks    -- Show CI status for a single pull request
close     -- Close a pull request
create    -- Create a pull request
diff      -- View changes in a pull request
list      -- List and filter pull requests in this repository
merge     -- Merge a pull request
ready     -- Mark a pull request as ready for review
reopen    -- Reopen a pull request
review    -- Add a review to a pull request
status    -- Show status of relevant pull requests
view      -- View a pull request
pr했다.create의 도움말을 읽습니다. create와 --title는 제목과 본문을 지정할 수 있습니다. --body는 목적지를 통합하는 지점을 지정할 수 있습니다. 이 지점을 지정하십시오.$ git add articles
$ git commit -m "Add my first article on Zenn"
$ git push -u origin first-article
$ gh pr create --base master --title "Add my first article on Zenn close #1" --body "This pull request was created by gh"
                                                                                                                                                                                                                                              
Creating pull request for first-article into master in morinokami/zenn-docs                                                                                                                                                                   
                                                                                                                                                                                                                                              
https://github.com/morinokami/zenn-docs/pull/2
--base 및 status를 통해 확인할 수 있습니다.$ gh pr status                                                                                                                                                                                                  
Relevant pull requests in morinokami/zenn-docs
Current branch
  #2  Add my first article on Zenn close #1 [first-article]
Created by you
  #2  Add my first article on Zenn close #1 [first-article]
Requesting a code review from you
  You have no pull requests to review
$ gh pr view 2                                                                                                                                                                                                  
Add my first article on Zenn close #1
Open • morinokami wants to merge 1 commit into master from first-article
  This pull request was created by gh
View this pull request on GitHub: https://github.com/morinokami/zenn-docs/pull/2
코멘트
마지막으로 나는 자신감 있게 방금 요구한 것을 논평하고 합병할 것이다.우선 diff 확인:
$ gh pr diff                                                                                                                                                                                                    
diff --git a/articles/hello-github-cli.md b/articles/hello-github-cli.md
new file mode 100644
index 0000000..aa14ce9
--- /dev/null
+++ b/articles/hello-github-cli.md
@@ -0,0 +1,300 @@
+---
+title: "GitHub CLI 1.0 がリリースされたので使ってみた" # 記事のタイトル
+emoji: "😸" # アイキャッチとして使われる絵文字(1文字だけ)
+type: "tech" # tech: 技術記事 / idea: アイデア記事
+topics: ["gh", "GitHub CLI"] # タグ。["markdown", "rust", "aws"]のように指定する
+published: true # 公開設定(falseにすると下書き)
+---
+
...
$ gh pr merge -m 2
✔ Merged pull request #2 (Add my first article on Zenn close #1)
✔ Deleted branch first-article and switched to branch master
끝맺다
이 글은 GiitHub CLI의 사용감을 확인하기 위해 실제 몇 개의 하위 명령을 사용한 상황을 보고했다.저뷰 명령는 지금까지 사용하지 않았습니다. 브라우저에서GiitHub을 조작하고 있기 때문에 터미널로부터의 조작이 얼마나 수월한지 실감할 수 있습니다.하위 명령에 대해서도 일관성이 명확하고 도움말 등이 충실해 향후 GiitHub CLI를 꾸준히 사용할 예정이다.
Reference
이 문제에 관하여(GiitHub CLI 1.0이 출시되었기 때문에), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/morinokami/articles/hello-github-cli텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)