From dc99730a8b0c1783bb34c8d0933f8d42698018bc Mon Sep 17 00:00:00 2001 From: Adam Williams Date: Thu, 15 Dec 2011 11:04:12 -0500 Subject: [PATCH] GLI basics, with Aruba/Cucumber in place. Note that there is Gemfile in octopress subdir - what is going to be the new root structure at some point. --- octopress/.gitignore | 1 + octopress/Gemfile | 2 + octopress/Gemfile.lock | 50 ++++++++++++++++++++++++ octopress/README.rdoc | 6 +++ octopress/Rakefile | 24 ++++++++++++ octopress/TODO.txt | 52 +++++++++++++++++++++++++ octopress/bin/octopress | 61 ++++++++++++++++++++++++++++++ octopress/features/create.feature | 5 +++ octopress/features/support/env.rb | 1 + octopress/lib/octopress_version.rb | 3 ++ octopress/octopress.gemspec | 24 ++++++++++++ octopress/octopress.rdoc | 5 +++ 12 files changed, 234 insertions(+) create mode 100644 octopress/.gitignore create mode 100644 octopress/Gemfile create mode 100644 octopress/Gemfile.lock create mode 100644 octopress/README.rdoc create mode 100644 octopress/Rakefile create mode 100644 octopress/TODO.txt create mode 100755 octopress/bin/octopress create mode 100644 octopress/features/create.feature create mode 100644 octopress/features/support/env.rb create mode 100644 octopress/lib/octopress_version.rb create mode 100644 octopress/octopress.gemspec create mode 100644 octopress/octopress.rdoc diff --git a/octopress/.gitignore b/octopress/.gitignore new file mode 100644 index 0000000..501e77d --- /dev/null +++ b/octopress/.gitignore @@ -0,0 +1 @@ +vendor/ruby diff --git a/octopress/Gemfile b/octopress/Gemfile new file mode 100644 index 0000000..e45e65f --- /dev/null +++ b/octopress/Gemfile @@ -0,0 +1,2 @@ +source :rubygems +gemspec diff --git a/octopress/Gemfile.lock b/octopress/Gemfile.lock new file mode 100644 index 0000000..3f5b1a0 --- /dev/null +++ b/octopress/Gemfile.lock @@ -0,0 +1,50 @@ +PATH + remote: . + specs: + octopress (0.0.1) + gli (~> 1.4.0) + +GEM + remote: http://rubygems.org/ + specs: + aruba (0.4.9) + childprocess (>= 0.2.3) + cucumber (>= 1.1.1) + ffi (= 1.0.11) + rspec (>= 2.7.0) + builder (3.0.0) + childprocess (0.2.3) + ffi (~> 1.0.6) + cucumber (1.1.4) + builder (>= 2.1.2) + diff-lcs (>= 1.1.2) + gherkin (~> 2.7.1) + json (>= 1.4.6) + term-ansicolor (>= 1.0.6) + diff-lcs (1.1.3) + ffi (1.0.11) + gherkin (2.7.1) + json (>= 1.4.6) + gli (1.4.0) + json (1.6.3) + rake (0.9.2.2) + rdoc (3.11) + json (~> 1.4) + rspec (2.7.0) + rspec-core (~> 2.7.0) + rspec-expectations (~> 2.7.0) + rspec-mocks (~> 2.7.0) + rspec-core (2.7.1) + rspec-expectations (2.7.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.7.0) + term-ansicolor (1.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + aruba (~> 0.4.9) + octopress! + rake + rdoc diff --git a/octopress/README.rdoc b/octopress/README.rdoc new file mode 100644 index 0000000..e87f829 --- /dev/null +++ b/octopress/README.rdoc @@ -0,0 +1,6 @@ += octopress + +Describe your project here + +:include:octopress.rdoc + diff --git a/octopress/Rakefile b/octopress/Rakefile new file mode 100644 index 0000000..30aa023 --- /dev/null +++ b/octopress/Rakefile @@ -0,0 +1,24 @@ +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 = 'Octopress' +end + +spec = eval(File.read('octopress.gemspec')) + +Gem::PackageTask.new(spec) do |pkg| +end + +require 'cucumber' +require 'cucumber/rake/task' +Cucumber::Rake::Task.new(:features) do |t| + t.cucumber_opts = "features --format pretty -x" + t.fork = false +end + +task :default => :features diff --git a/octopress/TODO.txt b/octopress/TODO.txt new file mode 100644 index 0000000..a725a75 --- /dev/null +++ b/octopress/TODO.txt @@ -0,0 +1,52 @@ +octopress --global-option command -d myblog + +octopress --path /my/blog post --option new "Hello" + +todo -f /path/to/file.txt add -f "Call brandon" + + +# Replace the install command of the Rakefile +octopress + create [DIRECTORY] # Create a new Jekyll blog. + --theme=classic (aliases -t) + --deploy={rsync,github,aws,heroku} + --root-dir=/ + + clean # Clean out caches: .pygments-cache, +.gist-cache, .sass-cache + + deploy # Deploy compiled site + --default={rsync,github,aws,heroku} + --rsync + --github + --aws + --heroku + + generate + + octopress new-page TITLE + + SYNOPSIS + octopress new-post [-s] + -s FILENAME, --slug + -i, --isolate + + SYNOPSIS + git add [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p] + [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N] + [--refresh] [--ignore-errors] [--ignore-missing] [--] + [...] + + + + isolate TITLE + + integrate + + preview + + theme update + theme install + theme create + + watch diff --git a/octopress/bin/octopress b/octopress/bin/octopress new file mode 100755 index 0000000..971d838 --- /dev/null +++ b/octopress/bin/octopress @@ -0,0 +1,61 @@ +#!/usr/bin/env ruby + +$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib') +require 'rubygems' +require 'gli' +require 'octopress_version' + +include GLI + +program_desc 'A blogging framework for hackers.' + +version Octopress::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 'Describe create here' +arg_name 'Describe arguments to create here' +command :create do |c| + c.desc 'Describe a switch to create' + c.switch :s + + c.desc 'Describe a flag to create' + c.default_value 'default' + c.flag :f + c.action do |global_options,options,args| + puts "Hello!" + # Your command logic here + + # If you have any errors, just raise them + # raise "that command made no sense" + end +end + +pre do |global,command,options,args| + # Pre logic here + # Return true to proceed; false to abourt 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 GLI.run(ARGV) diff --git a/octopress/features/create.feature b/octopress/features/create.feature new file mode 100644 index 0000000..7726a46 --- /dev/null +++ b/octopress/features/create.feature @@ -0,0 +1,5 @@ +Feature: Create a new Octopress Blog + + Scenario: create with no flags, switches or arguments + When I successfully run `octopress create` + Then the stdout should contain "Hello!" diff --git a/octopress/features/support/env.rb b/octopress/features/support/env.rb new file mode 100644 index 0000000..fb0a661 --- /dev/null +++ b/octopress/features/support/env.rb @@ -0,0 +1 @@ +require 'aruba/cucumber' diff --git a/octopress/lib/octopress_version.rb b/octopress/lib/octopress_version.rb new file mode 100644 index 0000000..7f0497d --- /dev/null +++ b/octopress/lib/octopress_version.rb @@ -0,0 +1,3 @@ +module Octopress + VERSION = '0.0.1' +end diff --git a/octopress/octopress.gemspec b/octopress/octopress.gemspec new file mode 100644 index 0000000..d51e541 --- /dev/null +++ b/octopress/octopress.gemspec @@ -0,0 +1,24 @@ +# Ensure we require the local version and not one we might have installed already +require File.join([File.dirname(__FILE__),'lib','octopress_version.rb']) +spec = Gem::Specification.new do |s| + s.name = 'octopress' + s.version = Octopress::VERSION + s.author = 'Brandon Mathis' + s.email = 'brandon@imathis.com' + s.homepage = 'http://octopress.org' + s.platform = Gem::Platform::RUBY + s.summary = 'Octopress is a framework designed for Jekyll, the blog aware static site generator powering Github Pages.' + s.files = %w( +bin/octopress + ) + s.require_paths << 'lib' + s.has_rdoc = true + s.extra_rdoc_files = ['README.rdoc','octopress.rdoc'] + s.rdoc_options << '--title' << 'octopress' << '--main' << 'README.rdoc' << '-ri' + s.bindir = 'bin' + s.executables << 'octopress' + s.add_dependency('gli', '~> 1.4.0') + s.add_development_dependency('rake') + s.add_development_dependency('rdoc') + s.add_development_dependency('aruba', '~> 0.4.9') +end diff --git a/octopress/octopress.rdoc b/octopress/octopress.rdoc new file mode 100644 index 0000000..b56cb07 --- /dev/null +++ b/octopress/octopress.rdoc @@ -0,0 +1,5 @@ += octopress + +Generate this with + octopress rdoc +After you have described your command line interface \ No newline at end of file