Class: RSMP::SXLCLI

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

Overview

CLI subcommands for SXL dependency resolution and manifests.

Instance Method Summary collapse

Instance Method Details

#resolve(*roots) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rsmp/cli.rb', line 38

def resolve(*roots)
  raise RSMP::SXL::Processing::Error, 'sxl resolve requires at least one root' if roots.empty?

  ensure_manifest_output_available!
  catalogue = RSMP::SXL::Processing::Catalogue.new(options[:source])
  requirements = roots.map { |root| root_requirement(root, catalogue) }
  documents = RSMP::SXL::Processing::Resolver.new(catalogue).resolve(requirements)
  manifest = RSMP::SXL::Processing::Manifest.create(documents, format: options[:format])
  write_manifest(manifest)
  puts "Wrote #{options[:out]}"
rescue RSMP::SXL::Processing::Error, SystemCallError => e
  fail_sxl_command(e)
end

#verify(path = 'manifest.yaml') ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/rsmp/cli.rb', line 55

def verify(path = 'manifest.yaml')
  catalogue = RSMP::SXL::Processing::Catalogue.new(options[:source])
  manifest = RSMP::SXL::Processing::Manifest.load(path)
  RSMP::SXL::Processing::Manifest.verify!(manifest, catalogue)
  puts 'OK'
rescue RSMP::SXL::Processing::Error, SystemCallError => e
  fail_sxl_command(e)
end