class Khaleesi::CLI
Public Class Methods
class_from_arg(arg)
click to toggle source
# File lib/khaleesi/cli.rb, line 35 def self.class_from_arg(arg) case arg when 'construction', 'c' Construction when 'createpost', 'cp' CreatePost when 'generate', 'g' Generate when 'version', 'v' Version when 'produce', 'p' Produce when 'build', 'b' Build when 'help', 'h' Help else About end end
doc() { |'usage: khaleesi [command] [args...]'| ... }
click to toggle source
# File lib/khaleesi/cli.rb, line 5 def self.doc return enum_for(:doc) unless block_given? yield 'usage: khaleesi [command] [args...]' yield '' yield 'where <command> is one of:' yield %| help\|h #{Help.desc}| yield %| version\|v #{Version.desc}| yield %| about #{About.desc}| yield %| produce\|p #{Produce.desc}| yield %| construction\|c #{Construction.desc}| yield %| createpost\|cp #{CreatePost.desc}| yield %| generate\|g #{Generate.desc}| yield %| build\|b #{Build.desc}| yield '' yield 'See `khaleesi help <command>` for more info.' end
new(options={})
click to toggle source
# File lib/khaleesi/cli.rb, line 23 def initialize(options={}) end
normalize_syntax(argv)
click to toggle source
# File lib/khaleesi/cli.rb, line 625 def self.normalize_syntax(argv) out = [] argv.each do |arg| case arg when /^(-{,2})(\p{Graph}+)=(.*)$/ out << $2 << $3 when /^(-{,2})(\p{Graph}+)$/ out << $2 else out << arg end end out end
parse(argv=ARGV)
click to toggle source
# File lib/khaleesi/cli.rb, line 26 def self.parse(argv=ARGV) argv = normalize_syntax(argv) mode = argv.shift klass = class_from_arg(mode) klass.parse(argv) end
Public Instance Methods
create_file_p(dir, name, extension)
click to toggle source
# File lib/khaleesi/cli.rb, line 617 def create_file_p(dir, name, extension) unless File.directory?(dir) FileUtils.mkdir_p(dir) end "#{dir}/#{name}" + (extension.empty? ? '' : ".#{extension}") end