Class: Toy::Core::CLI::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/toy/core/cli/manifest.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Manifest

Returns a new instance of Manifest.



18
19
20
# File 'lib/toy/core/cli/manifest.rb', line 18

def initialize(argv)
  @argv = argv
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/toy/core/cli/manifest.rb', line 22

def run
  commands = COMMANDS.map do |name, entry|
    {
      "name" => name,
      "summary" => entry[:summary],
      "args" => entry[:args],
      "flags" => entry[:flags]
    }
  end

  manifest = {
    "format" => "toy/manifest-v1",
    "toy_version" => Toy::VERSION,
    "commands" => commands,
    "global_flags" => GLOBAL_FLAGS,
    "exit_codes" => {
      "ok" => EXIT_OK,
      "bad_input" => EXIT_BAD_INPUT,
      "failure" => EXIT_FAILURE
    }
  }
  puts JSON.pretty_generate(manifest)
  EXIT_OK
end