<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: WessCoby</title>
    <description>The latest articles on DEV Community by WessCoby (@wesscoby).</description>
    <link>https://dev.to/wesscoby</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F175740%2F0b6000e6-f88e-4468-81eb-2b5f64c17fc2.jpeg</url>
      <title>DEV Community: WessCoby</title>
      <link>https://dev.to/wesscoby</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wesscoby"/>
    <language>en</language>
    <item>
      <title>Github CLI: An Introduction</title>
      <dc:creator>WessCoby</dc:creator>
      <pubDate>Tue, 22 Sep 2020 11:47:04 +0000</pubDate>
      <link>https://dev.to/wesscoby/github-cli-an-introduction-2e68</link>
      <guid>https://dev.to/wesscoby/github-cli-an-introduction-2e68</guid>
      <description>&lt;p&gt;Earlier this year, Github announced the beta version of &lt;code&gt;Github CLI&lt;/code&gt;, a new command-line tool for developers. This tool, according to the team, is supposed to reduce context switching and help the developer run their entire workflow right from the terminal. Cool right? #LetsTalkAboutIt&lt;/p&gt;

&lt;h4&gt;
  
  
  Scenario
&lt;/h4&gt;

&lt;p&gt;In your local repository, you use &lt;code&gt;git&lt;/code&gt; in the terminal for staging, committing, and pushing changes to your remote repository. Once you're done, you then switch to Github in the browser for tasks like managing issues, pull requests, etc&lt;/p&gt;

&lt;p&gt;Now imagine having to do this about fifty times a day (or even more), coupled with the stress from the actual job - coding and debugging. Now that's something&lt;/p&gt;

&lt;h4&gt;
  
  
  Enter Github CLI
&lt;/h4&gt;

&lt;p&gt;Github CLI offers a solution to this problem. You can perform all the browser-related tasks and even more, right in the terminal - you don't have to switch. In addition, you get access to an API that you can use to customize your experience. But enough of the chit chat. Let's dive into using &lt;code&gt;gh&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Detailed installation instructions are available in the &lt;a href="https://github.com/cli/cli#installation"&gt;README&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Windows
&lt;/h4&gt;

&lt;p&gt;MSI installers are available for download on the &lt;a href="https://github.com/cli/cli/releases/latest"&gt;releases page&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Via Scoop&lt;/span&gt;
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop &lt;span class="nb"&gt;install &lt;/span&gt;gh

&lt;span class="c"&gt;# Via Chocolatey&lt;/span&gt;
choco &lt;span class="nb"&gt;install &lt;/span&gt;gh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Mac OS
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Via Homebrew&lt;/span&gt;
brew &lt;span class="nb"&gt;install &lt;/span&gt;gh

&lt;span class="c"&gt;# Via MacPorts&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;port &lt;span class="nb"&gt;install &lt;/span&gt;gh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Linux
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Debian, Ubuntu Linux (apt)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key adv &lt;span class="nt"&gt;--keyserver&lt;/span&gt; keyserver.ubuntu.com &lt;span class="nt"&gt;--recv-key&lt;/span&gt; C99B11DEB97541F0
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-add-repository https://cli.github.com/packages
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;gh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For other Linux distros, please visit the install &lt;a href="https://github.com/cli/cli/blob/trunk/docs/install_linux.md"&gt;instructions page&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;p&gt;Check version to ensure it installed correctly. You should get response as below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gh version

&lt;span class="c"&gt;# gh version 1.0.0 (2020-09-16)&lt;/span&gt;
&lt;span class="c"&gt;# https://github.com/cli/cli/releases/tag/v1.0.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Authentication
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gh auth login
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The authentication process is quite smooth. The first prompt asks you to choose between Github and Github Enterprise. Then you will choose either to authenticate via the web browser or paste in a GitHub token (if you have a &lt;code&gt;GITHUB_TOKEN&lt;/code&gt; environment variable set, it will be used).&lt;/p&gt;

&lt;h3&gt;
  
  
  Commands
&lt;/h3&gt;

&lt;p&gt;The commands are pretty straight forward and easy to understand and use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gh &lt;span class="nb"&gt;help
&lt;/span&gt;Work seamlessly with GitHub from the &lt;span class="nb"&gt;command &lt;/span&gt;line.

USAGE
  gh &amp;lt;&lt;span class="nb"&gt;command&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &amp;lt;subcommand&amp;gt; &lt;span class="o"&gt;[&lt;/span&gt;flags]

CORE COMMANDS
  gist:       Create gists
  issue:      Manage issues
  &lt;span class="nb"&gt;pr&lt;/span&gt;:         Manage pull requests
  release:    Manage GitHub releases
  repo:       Create, clone, fork, and view repositories

ADDITIONAL COMMANDS
  &lt;span class="nb"&gt;alias&lt;/span&gt;:      Create &lt;span class="nb"&gt;command &lt;/span&gt;shortcuts
  api:        Make an authenticated GitHub API request
  auth:       Login, &lt;span class="nb"&gt;logout&lt;/span&gt;, and refresh your authentication
  completion: Generate shell completion scripts
  config:     Manage configuration &lt;span class="k"&gt;for &lt;/span&gt;gh
  &lt;span class="nb"&gt;help&lt;/span&gt;:       Help about any &lt;span class="nb"&gt;command

&lt;/span&gt;FLAGS
  &lt;span class="nt"&gt;--help&lt;/span&gt;      Show &lt;span class="nb"&gt;help &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt;
  &lt;span class="nt"&gt;--version&lt;/span&gt;   Show gh version

EXAMPLES
  &lt;span class="nv"&gt;$ &lt;/span&gt;gh issue create
  &lt;span class="nv"&gt;$ &lt;/span&gt;gh repo clone cli/cli
  &lt;span class="nv"&gt;$ &lt;/span&gt;gh &lt;span class="nb"&gt;pr &lt;/span&gt;checkout 321

ENVIRONMENT VARIABLES
  See &lt;span class="s1"&gt;'gh help environment'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;the list of supported environment variables.

LEARN MORE
  Use &lt;span class="s1"&gt;'gh &amp;lt;command&amp;gt; &amp;lt;subcommand&amp;gt; --help'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;more information about a command.
  Read the manual at https://cli.github.com/manual

FEEDBACK
  Open an issue using &lt;span class="s1"&gt;'gh issue create -R cli/cli'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's take the &lt;code&gt;repo subcommand&lt;/code&gt;, for instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gh repo --help
Work with GitHub repositories

USAGE
  gh repo &amp;lt;command&amp;gt; [flags]

CORE COMMANDS
  clone:      Clone a repository locally
  create:     Create a new repository
  fork:       Create a fork of a repository
  view:       View a repository

INHERITED FLAGS
  --help   Show help for command

ARGUMENTS
  A repository can be supplied as an argument in any of the following formats:
  - "OWNER/REPO"
  - by URL, e.g. "https://github.com/OWNER/REPO"

EXAMPLES
  $ gh repo create
  $ gh repo clone cli/cli
  $ gh repo view --web

LEARN MORE
  Use 'gh &amp;lt;command&amp;gt; &amp;lt;subcommand&amp;gt; --help' for more information about a command.
  Read the manual at https://cli.github.com/manual
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Cloning a repository &lt;a href="https://github.com/OWNER/REPO:"&gt;https://github.com/OWNER/REPO:&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gh repo clone OWNER/REPO

&lt;span class="c"&gt;# if you own the repo, all you need is the repo name&lt;/span&gt;
gh repo clone REPO
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's explore the &lt;code&gt;alias&lt;/code&gt; subcommand&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gh &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nt"&gt;--help&lt;/span&gt;
Aliases can be used to make shortcuts &lt;span class="k"&gt;for &lt;/span&gt;gh commands or to compose multiple commands.

Run &lt;span class="s2"&gt;"gh help alias set"&lt;/span&gt; to learn more.


USAGE
  gh &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;flags]

CORE COMMANDS
  delete:     Delete an &lt;span class="nb"&gt;alias
  &lt;/span&gt;list:       List your aliases
  &lt;span class="nb"&gt;set&lt;/span&gt;:        Create a shortcut &lt;span class="k"&gt;for &lt;/span&gt;a gh &lt;span class="nb"&gt;command

&lt;/span&gt;INHERITED FLAGS
  &lt;span class="nt"&gt;--help&lt;/span&gt;   Show &lt;span class="nb"&gt;help &lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;command

&lt;/span&gt;LEARN MORE
  Use &lt;span class="s1"&gt;'gh &amp;lt;command&amp;gt; &amp;lt;subcommand&amp;gt; --help'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;more information about a command.
  Read the manual at https://cli.github.com/manual
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's set an alias &lt;code&gt;il&lt;/code&gt; for listing issues on a repo and use it to access issues list on my repo &lt;code&gt;wesscoby/wesscoby&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;gh &lt;span class="nb"&gt;alias set &lt;/span&gt;il &lt;span class="s1"&gt;'issue list'&lt;/span&gt; 

&lt;span class="c"&gt;# - Adding alias for il: issue list&lt;/span&gt;
&lt;span class="c"&gt;# ✓ Added alias.&lt;/span&gt;

~                                                                              
gh &lt;span class="nb"&gt;alias &lt;/span&gt;list

&lt;span class="c"&gt;# co:  pr checkout&lt;/span&gt;
&lt;span class="c"&gt;# il:  issue list&lt;/span&gt;


gh il &lt;span class="nt"&gt;--repo&lt;/span&gt; wesscoby/wesscoby

&lt;span class="c"&gt;# Showing 2 of 2 open issues in wesscoby/wesscoby&lt;/span&gt;

&lt;span class="c"&gt;#3  Fix Portfolio links     about 3 days ago&lt;/span&gt;
&lt;span class="c"&gt;#2  Resume Download Link &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see, the tool is very well documented, providing rich user experience. &lt;br&gt;
You can also access the &lt;a href="https://cli.github.com/manual/"&gt;docs website&lt;/a&gt; for more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;This is indeed a great tool made by developers for developers like myself, who enjoy working in the terminal. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
