OpenShift Cookbook
上QQ阅读APP看书,第一时间看更新

Installing the OpenShift rhc command-line client

The rhc client is the most powerful and feature-rich command-line client utility, which users can use to work with OpenShift. It is built using Ruby programming language and packaged as a Ruby gem. The rhc source code is available on GitHub at https://github.com/openshift/rhc.

Getting ready

To install rhc, you will need to have Ruby 1.8.7 or above installed on your machine. You can check whether Ruby is installed on your machine by running the following command:

$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

The output of the preceding command will depend on the operating system and Ruby version installed on your machine. If you receive ruby: command not found, then Ruby is not installed on your machine. Install Ruby on your operating system. You can download the package for your operating system from the official website at https://www.ruby-lang.org/en/downloads/.

How to do it…

Open a new command-line terminal and run the following command:

$ gem install rhc

This command will install the rhc gem required to work with OpenShift.

How it works…

OpenShift packages the rhc command-line utility as a gem. A gem is a reusable piece of code or a command-line utility to help automate tasks. RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries. This software allows a developer to download, install, and use software packages on their machine. The gem command allows you to work with RubyGems.

When you run the gem install command, the gem command-line tool fetches the package and its dependencies from the central repository and installs them. The central gem repository is available at http://rubygems.org.

After the command successfully finishes, you can check the version of rhc using the following command:

$ rhc --version
rhc 1.27.4

There's more…

The gem install command also generates the documentation for the installed packages. You can use the Ruby ri command-line tool to view the documentation offline. For example, if you want to list all the classes for which ri can show documentation, then run the following command:

$ ri --list

This command will list all the classes and their methods for which you can view the documentation. To view the documentation of the CLI class method of the RHC class, execute the following command:

$ ri RHC::CLI

The output will be the documentation for the CLI method, as follows:

= RHC::CLI
(from gem rhc-1.27.4)
------------------------------------------------------------------------------
Run and execute a command line session with the RHC tools.

You can invoke the CLI with:
 bundle exec ruby -e 'require 'rhc/cli'; RHC::CLI.start(ARGV);' -- <arguments>

You can disable the documentation generation by using the following command:

$ gem install rhc --no-document

See also

  • The Setting up an OpenShift account using rhc recipe
  • The Updating rhc recipe