Sha256: 9bb4d9a52494f113b24765b206b8b1ba8ca6bfacf48383b15605b21edeb58fa4

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'thor'
require 'guard/version'

module Guard
  class CLI < Thor
    default_task :start
    
    desc "start", "Starts guard"
    method_option :clear, :type => :boolean, :default => false, :aliases => '-c', :banner => "Auto clear shell after each change"
    def start
      Guard.start(options)
    end
    
    desc "version", "Prints the guard's version information"
    def version
      Guard::UI.info "Guard version #{Guard::VERSION}"
    end
    map %w(-v --version) => :version
    
    desc "init [GUARD]", "Generates a Guardfile into the current working directory, or add it given guard"
    def init(guard_name = nil)
      if !File.exist?("Guardfile")
        puts "Writing new Guardfile to #{Dir.pwd}/Guardfile"
        FileUtils.cp(File.expand_path('../templates/Guardfile', __FILE__), 'Guardfile')
      elsif guard_name.nil?
        Guard::UI.error "Guardfile already exists at #{Dir.pwd}/Guardfile"
        exit 1
      end
      
      if guard_name
        guard_class = Guard.get_guard_class(guard_name)
        guard_class.init(guard_name)
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
guard-0.1.0.beta.2 lib/guard/cli.rb