Created
September 19, 2013 09:41
-
-
Save torstello/6621247 to your computer and use it in GitHub Desktop.
ruby::template: git-like-cli-bin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'gli' | |
begin # XXX: Remove this begin/rescue before distributing your app | |
require 'git_like_interface' | |
rescue LoadError | |
STDERR.puts "In development, you need to use `bundle exec bin/git_like_interface` to run your app" | |
STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path" | |
STDERR.puts "Feel free to remove this message from bin/git_like_interface now" | |
exit 64 | |
end | |
include GLI::App | |
program_desc 'Describe your application here' | |
version GitLikeInterface::VERSION | |
desc 'Describe some switch here' | |
switch [:s,:switch] | |
desc 'Describe some flag here' | |
default_value 'the default' | |
arg_name 'The name of the argument' | |
flag [:f,:flagname] | |
pre do |global,command,options,args| | |
# Pre logic here | |
# Return true to proceed; false to abort and not call the | |
# chosen command | |
# Use skips_pre before a command to skip this block | |
# on that command only | |
true | |
end | |
post do |global,command,options,args| | |
# Post logic here | |
# Use skips_post before a command to skip this | |
# block on that command only | |
end | |
on_error do |exception| | |
# Error logic here | |
# return false to skip default error handling | |
true | |
end | |
exit run(ARGV) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment