Putting together a basic squib new command
parent
a6eed0ad3d
commit
b64e88ed0e
17
bin/squib
17
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 <subcommand> [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
|
||||
14
lib/squib.rb
14
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'
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
_output
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
My Awesome Game
|
||||
===============
|
||||
|
||||
Check out my awesome game!
|
||||
|
||||
|
||||
Objective
|
||||
---------
|
||||
|
||||
|
||||
|
||||
Gameplay
|
||||
--------
|
||||
|
||||
|
||||
|
||||
Ending the Game
|
||||
---------------
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'squib'
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Print and Play Notes
|
||||
====================
|
||||
|
||||
Fill this out to give tips on how to play this with print and play.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
require 'squib'
|
||||
|
||||
Squib::Deck.new(cards: 3) do
|
||||
text str: "Hello, World!"
|
||||
save format: :png
|
||||
end
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue