Class: AnnotateModel::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate_model/cli.rb

Class Method Summary collapse

Class Method Details

.start(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/annotate_model/cli.rb', line 3

def self.start(args)
  options = {}
  OptionParser.new do |opts|
    opts.banner = "Usage: annotate models [options] [model_name]"

    opts.on("-a", "--all", "Annotate all models") do |a|
      options[:all] = a
    end

    opts.on("-h", "--help", "Prints this help") do
      puts opts
      exit
    end
  end.parse!(args)

  if options[:all] || args.empty?
    AnnotateModel::Annotator.annotate_all
  else
    AnnotateModel::Annotator.annotate(args)
  end
end