Sha256: 99ec6d3e20084f1c894a32b6b4b3083657599ce69676b063054ba0826366e7f3
Contents?: true
Size: 876 Bytes
Versions: 1
Compression:
Stored size: 876 Bytes
Contents
require 'thor' module ExtensionLister class CLI < Thor desc 'list', 'List all unique extensions' method_option "base_dir", aliases: "-b", desc: "Base directory", default: File.expand_path(".") method_option 'version', aliases: '-v', desc: 'Display version number' def list opts = options.symbolize_keys if opts[:version] puts "You are using ExtensionLister version #{ExtensionLister::VERSION}" exit end puts list_extensions(opts[:base_dir]) end private def list_extensions(base_dir = ".") extensions = Dir.glob(File.join(File.expand_path(base_dir), "**/*")).reduce([]) do |exts, file| exts << File.extname(file) end extensions.sort.uniq.delete_if { |e| e == "" } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
extension_lister-0.1.0 | lib/extension_lister/cli.rb |