Skip to content

Instantly share code, notes, and snippets.

@nikushi
Last active December 14, 2015 12:29
Show Gist options
  • Save nikushi/5086723 to your computer and use it in GitHub Desktop.
Save nikushi/5086723 to your computer and use it in GitHub Desktop.
$ bundle gem myapp; cd myapp
$ mkdir bin
$ vim bin/myapp
#!/usr/bin/env ruby
require 'pathname'
lib = Pathname.new(__FILE__).dirname.join('..', 'lib').expand_path
$LOAD_PATH.unshift lib.to_s
require 'myapp'
Myapp::CLI.start
$ vim lib/myapp.rb
require "myapp/version"
require "myapp/cli"
module Myapp
# Your code goes here...
end
$ vim lib/myapp/cli.rb
require 'thor'
module Myapp
class CLI < Thor
desc 'list', 'list something'
def list
puts 'write something to list'
end
end
end
$ vim myapp.gemspec
..snip..
gem.description = ["something write here"]
gem.summary = ["command to do something"]
..snip..
gem.add_dependency('thor', '~> 0.17.0')
$ bundle install
$ bundle exec ruby bin/myapp
Tasks:
myapp help [TASK] # Describe available tasks or one specific task
myapp list # list something
$ git add -A
$ git ci -m 'Initial'
$ gem build myapp.gemspec # => ./myapp-0.0.1.gem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment