Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
initial setup
  • Loading branch information
chumpy committed Mar 16, 2012
0 parents commit 491a8ae
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.swp
.git
.rvmrc
2 changes: 2 additions & 0 deletions Gemfile
@@ -0,0 +1,2 @@
source :rubygems
gemspec
4 changes: 4 additions & 0 deletions README.md
@@ -0,0 +1,4 @@
= calamity

A life hacking tool for the command line.

23 changes: 23 additions & 0 deletions Rakefile
@@ -0,0 +1,23 @@
require 'rake/clean'
require 'rubygems'
require 'rubygems/package_task'
require 'rdoc/task'

Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
rd.title = 'Your application title'
end

spec = eval(File.read('calamity.gemspec'))

Gem::PackageTask.new(spec) do |pkg|
end

require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/tc_*.rb']
end

task :default => :test
86 changes: 86 additions & 0 deletions bin/calamity
@@ -0,0 +1,86 @@
#!/usr/bin/env ruby
# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
# have this method, so we add it so we get resolved symlinks
# and compatibility
unless File.respond_to? :realpath
class File #:nodoc:
def self.realpath path
return realpath(File.readlink(path)) if symlink?(path)
path
end
end
end
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
require 'rubygems'
require 'gli'
require 'calamity_version'

include GLI

program_desc 'Calamity is a life hacking tool'

version Calamity::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]

desc 'Add a task'
arg_name 'Describe arguments to add here'
command :add do |c|
c.desc 'Describe a switch to add'
c.switch :s

c.desc 'Describe a flag to add'
c.default_value 'default'
c.flag :f
c.action do |global_options,options,args|

# Your command logic here

# If you have any errors, just raise them
# raise "that command made no sense"
end
end

desc 'Describe list here'
arg_name 'Describe arguments to list here'
command :list do |c|
c.action do |global_options,options,args|
end
end

desc 'Describe done here'
arg_name 'Describe arguments to done here'
command :done do |c|
c.action do |global_options,options,args|
end
end

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|
puts exception
# Error logic here
# return false to skip default error handling
true
end

exit GLI.run(ARGV)
23 changes: 23 additions & 0 deletions calamity.gemspec
@@ -0,0 +1,23 @@
# Ensure we require the local version and not one we might have installed already
require File.join([File.dirname(__FILE__),'lib','calamity_version.rb'])
spec = Gem::Specification.new do |s|
s.name = 'calamity'
s.version = Calamity::VERSION
s.author = 'Kevin Beddingfield'
s.email = 'kevin.beddingfield@gmail.com'
s.homepage = 'http://kevinbeddingfield.com'
s.platform = Gem::Platform::RUBY
s.summary = 'A life hacking tool'
# Add your other files here if you make them
s.files = %w(
bin/calamity
)
s.require_paths << 'lib'
s.has_rdoc = true
s.extra_rdoc_files = ['README.rdoc','calamity.rdoc']
s.rdoc_options << '--title' << 'calamity' << '--main' << 'README.rdoc' << '-ri'
s.bindir = 'bin'
s.executables << 'calamity'
s.add_development_dependency('rake')
s.add_development_dependency('rdoc')
end
5 changes: 5 additions & 0 deletions calamity.rdoc
@@ -0,0 +1,5 @@
= calamity

Generate this with
calamity rdoc
After you have described your command line interface
3 changes: 3 additions & 0 deletions lib/calamity_version.rb
@@ -0,0 +1,3 @@
module Calamity
VERSION = '0.0.1'
end
16 changes: 16 additions & 0 deletions test/tc_calamity.rb
@@ -0,0 +1,16 @@
require 'test/unit'
require 'date'

class TC_testCalamity < Test::Unit::TestCase

def setup
end

def teardown
end

def test_add_default_date
`./bin/calamity add -d foo`
#assert `./bin/calamity list foo | grep 'foo' | awk '{print $2}'` == "#{Date.today}"
end
end

0 comments on commit 491a8ae

Please sign in to comment.