This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
Creating a new command
Alex Chesters edited this page Oct 16, 2015
·
3 revisions
- Create a new file in the commands directory named
my-command.rb
- Do your work in
my-command.rb
. This file should be in a similar format to below (it must contain an execute function and an options function):module GHI module Commands class My Command < Command def options OptionParser.new do |opts| opts.banner = 'usage: ghi enable' opts.on '-a', '--all', 'some flag information' do object[:key] = 'value' end end end def execute begin options.parse! args @repo ||= ARGV[0] if ARGV.one? rescue OptionParser::InvalidOption => e fallback.parse! e.args retry end puts "Hello, world!" end end end end
- Add your new file to the build manifest in the
Rakefile
- Add your new command to
commands.rb
- Add your new command to
ghi help