Class: Btape::GenerateCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/btape/generate_command.rb

Overview

btape generate — asks a model running on this machine for a tape and writes it out, having first checked that what came back is one.

It is a separate command rather than a flag on a recording because it records nothing: no browser is opened, and the answer is a file to read, edit and then run like any other tape.

Defined Under Namespace

Classes: Options

Constant Summary collapse

USAGE =
'Usage: btape generate [options] DESCRIPTION'

Instance Method Summary collapse

Constructor Details

#initialize(out: $stdout, err: $stderr, stdin: $stdin, generator: nil) ⇒ GenerateCommand

Returns a new instance of GenerateCommand.



22
23
24
25
26
27
# File 'lib/btape/generate_command.rb', line 22

def initialize(out: $stdout, err: $stderr, stdin: $stdin, generator: nil)
  @out = out
  @err = err
  @stdin = stdin
  @generator = generator
end

Instance Method Details

#run(argv) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/btape/generate_command.rb', line 29

def run(argv)
  options = Options.new(help: false, client: {}, verbose: false)
  words = parse_options(argv, options)
  return print_help if options.help

  write(generator(options).call(description(words), context: context(options)), options)
  0
end