Class: GeneSystem::Commands::RemoveManifest

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/gene_system/commands/remove_manifest.rb

Overview

Remove manifest command

Constant Summary collapse

DEFAULT_MANIFEST_NAME =

Default name of gene system manifest

'manifest.json'.freeze

Instance Method Summary collapse

Methods included from Helpers

#ask, #filters, #filters?, #skip?, #steps

Constructor Details

#initialize(options) ⇒ RemoveManifest

Returns a new instance of RemoveManifest.



12
13
14
15
16
# File 'lib/gene_system/commands/remove_manifest.rb', line 12

def initialize(options)
  @options = options
  @prompt = TTY::Prompt.new
  @manifest = nil
end

Instance Method Details

#runObject

Applies remove instructions from a manifest to the host system.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gene_system/commands/remove_manifest.rb', line 22

def run
  manifest_path = @options.manifest
  manifest_path ||= @prompt.ask(
    'Please enter the path to the configuration manifest',
    default: DEFAULT_MANIFEST_NAME
  )

  @manifest = GeneSystem::Manifest.new_from_file(manifest_path)
  platform = GeneSystem::Platform.new

  puts("REMOVE #{@manifest.name_and_version}")

  steps.each do |step|
    next if skip?(:remove, step, platform)

    vars = ask(step.remove.prompts)

    platform.execute_commands(
      step.remove.cmd,
      vars
    )
  end

  puts(
    "✔ Manifest #{@manifest.name_and_version} successfully removed"
  )
end