Class: Rebuild::CLI

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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  update: false,
}

Class Method Summary collapse

Class Method Details

.startObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rebuild/cli.rb', line 11

def start
  options = DEFAULT_OPTIONS

  opt = OptionParser.new
  opt.on('-f', '--force-update')  { |v| options[:update] = true }
  opt.on('-d', '--directory=VAL') { |v| options[:directory] = v }
  opt.on('-s', '--scriptdir=VAL') { |v| options[:scriptdir] = v }

  args = opt.parse!(ARGV)
  return show_usage if args.empty? && CommandLineTools.installed?

  CommandLineTools.install unless CommandLineTools.installed?
  License.agree            unless License.agreed?

  if args.any?
    stdin = STDIN.gets unless STDIN.isatty
    bootstrap(args, stdin, options)
  end
end