Sha256: 734c7a21707b75b1b4e36bc0689d609f4a45c6d9e27729b568f60ec5da18e72a

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

#!ruby

require "gitignore"
require "tty-prompt"

command = ARGV[0]

case command
when "list"
  Gitignore.list.each do |env|
    puts " - #{env}"
  end

when "generate", "g"
  envs = ARGV[1..-1]
  puts Gitignore.generate(envs)

when "create"
  prompt = TTY::Prompt.new

  env_list = Gitignore.list
  results = prompt.multi_select(
    "Select envs to generate the .gitignore?", env_list, filter: true
  )

  unless results.any?
    puts "No environment selected... exiting!"
    exit
  end

  file = File.open('.gitignore', 'w')
  file.write(Gitignore.generate(results))
  file.close

  puts "The .gitignore is generated!"

else
  puts <<~HELP
Usage: #{File.basename($0)} [command] [options]

Commonly used command are:
       list :     list all environment options
     create :     generate a .gitignore file using a interactive term ui
   generate :     generate a .gitignore file by all environment that you choose
  HELP
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitignore-cli-0.8.0 bin/gitignore