diff --git a/bin/squib b/bin/squib index 79b5f97..370c637 100755 --- a/bin/squib +++ b/bin/squib @@ -1,2 +1,19 @@ #!/usr/bin/env ruby require 'squib' +require 'mercenary' + +Mercenary.program(:squib) do |p| + p.version Squib::VERSION + p.description "A Ruby DSL for prototyping card games" + p.syntax "squib [options]" + + p.command(:new) do |c| + c.syntax "new PATH" + c.description "Creates a new Squib project scaffolding in PATH. Must be a new directory or already empty." + + c.action do |args, options| + Squib::Commands::New.new.process(args) + end + end + +end \ No newline at end of file diff --git a/lib/squib.rb b/lib/squib.rb index b0257da..86c9bd9 100644 --- a/lib/squib.rb +++ b/lib/squib.rb @@ -1,14 +1,4 @@ -require 'logger' - -module Squib - - def logger - @logger ||= Logger.new(STDOUT) - end - module_function :logger - -end - +require 'squib/version' +require 'squib/commands/new' require 'squib/deck' -require 'squib/card' - +require 'squib/card' \ No newline at end of file diff --git a/lib/squib/commands/new.rb b/lib/squib/commands/new.rb new file mode 100644 index 0000000..6b8063e --- /dev/null +++ b/lib/squib/commands/new.rb @@ -0,0 +1,23 @@ +module Squib + module Commands + class New + + def process(args) + raise ArgumentError.new('Please specify a path.') if args.empty? + + new_project_path = File.expand_path(args.join(" "), Dir.pwd) + template_path = File.expand_path('../project_template', File.dirname(__FILE__)) + + FileUtils.mkdir_p new_project_path + if !Dir["#{new_project_path}/**/*"].empty? + $stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting." + else + Dir.chdir(new_project_path) do + FileUtils.cp_r template_path + '/.', new_project_path + end + end + end + + end + end +end \ No newline at end of file diff --git a/lib/squib/project_template/.gitignore b/lib/squib/project_template/.gitignore new file mode 100644 index 0000000..d63f0bc --- /dev/null +++ b/lib/squib/project_template/.gitignore @@ -0,0 +1,2 @@ +_output + diff --git a/lib/squib/project_template/ABOUT.md b/lib/squib/project_template/ABOUT.md new file mode 100644 index 0000000..3c7b272 --- /dev/null +++ b/lib/squib/project_template/ABOUT.md @@ -0,0 +1,19 @@ +My Awesome Game +=============== + +Check out my awesome game! + + +Objective +--------- + + + +Gameplay +-------- + + + +Ending the Game +--------------- + diff --git a/lib/squib/project_template/Gemfile b/lib/squib/project_template/Gemfile new file mode 100644 index 0000000..8c59a6c --- /dev/null +++ b/lib/squib/project_template/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'squib' \ No newline at end of file diff --git a/lib/squib/project_template/PNP NOTES.md b/lib/squib/project_template/PNP NOTES.md new file mode 100644 index 0000000..19c72c3 --- /dev/null +++ b/lib/squib/project_template/PNP NOTES.md @@ -0,0 +1,4 @@ +Print and Play Notes +==================== + +Fill this out to give tips on how to play this with print and play. \ No newline at end of file diff --git a/lib/squib/project_template/config.yml b/lib/squib/project_template/config.yml new file mode 100644 index 0000000..e69de29 diff --git a/lib/squib/project_template/deck.rb b/lib/squib/project_template/deck.rb new file mode 100644 index 0000000..7267af3 --- /dev/null +++ b/lib/squib/project_template/deck.rb @@ -0,0 +1,6 @@ +require 'squib' + +Squib::Deck.new(cards: 3) do + text str: "Hello, World!" + save format: :png +end \ No newline at end of file diff --git a/lib/squib/project_template/layout.yml b/lib/squib/project_template/layout.yml new file mode 100644 index 0000000..e69de29 diff --git a/squib.gemspec b/squib.gemspec index 6d5aa28..059ce49 100644 --- a/squib.gemspec +++ b/squib.gemspec @@ -31,6 +31,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'pango', '~> 2.2.0' spec.add_runtime_dependency 'roo', '~> 1.13.2' spec.add_runtime_dependency 'rsvg2', '~> 2.2.0' + spec.add_runtime_dependency 'mercenary', '~> 0.3.4' spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake"