Sha256: f538ad285bf48f92bcb08592849fb9a87468bfd05e4822002cb3f17eb172bdd2

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'thor'
require 'rstrip/rstrip'
module Rstrip
  class CLI < Thor

    include Thor::Actions

    desc "config", "generate: to generate a .rstrip file. list: to show the files that will be operated on"
    long_desc <<-D
      config can receive two arguments.

      generate: Generate a .rstrip config file containing file extensions rstrip will operate on.Defaults to the current
                directory.Use --global true to generate .rstrip to the user's home directory.\n
      list:     Show the location of the .rstrip config file that will be used. And show a list of files that will be
                operated on based on the .rstrip config file
    D
    method_option :global, :type => :boolean, :aliases => "-g", :default => false
    def config(task)
      case task.downcase
      when 'generate'
        if options[:global]
          template("rstrip.tt.txt", "#{Dir.home}/.rstrip")
        else
          template("rstrip.tt.txt", "#{Dir.pwd}/.rstrip")
        end
      when 'list'
        Rstrip.list
      end
    end

    desc "process", "run rstrip in the current folder recursively"
    def process
      Rstrip.list.collect{ |f| Rstrip.process(f) }
    end

    def self.source_root
      File.dirname(__FILE__) + "/templates"
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rstrip-0.0.4 lib/rstrip/cli.rb
rstrip-0.0.3 lib/rstrip/cli.rb
rstrip-0.0.2 lib/rstrip/cli.rb