module GeneSystem::CLI::Commands
CLI
Actions
Public Class Methods
ask(prompts = [])
click to toggle source
Asks for user input when given prompts
@param prompts [Array]
@return Hashie::Mash
# File lib/gene_system/cli/commands.rb, line 56 def ask(prompts = []) answers = Hashie::Mash.new return answers if prompts.nil? cli = HighLine.new prompts.each do |prompt| resp = cli.ask(prompt.prompt) answers[prompt.var] = resp end answers end
install(args = [])
click to toggle source
Applies install instructions from a manifest to the host system
@param args [Array]
# File lib/gene_system/cli/commands.rb, line 35 def install(args = []) manifest = load_manifest(args) platform = GeneSystem::Platform.new manifest.steps.each do |step| next if skip?(step, platform) vars = ask(step.install.prompts) platform.execute_commands(step.install.cmd, vars) end GeneSystem::CLI.print_message("\nmanifest successfully installed") end
new(args = [])
click to toggle source
Creates a new, blank manifest with at the specified destination with the given name
It is expected that the first argument provided to the command will be the name of the manifest. If this is not provided then a RuntimeError will be raised.
@param dest [String] @param args [Array]
# File lib/gene_system/cli/commands.rb, line 19 def new(args = []) manifest_name = args.shift raise 'no manifest name provided' unless manifest_name GeneSystem::Generators.render_empty_manifest( manifest_name, Dir.pwd ) end
remove(args = [])
click to toggle source
Applies remove instructions from a manifest to the host system
@param args [Array]
# File lib/gene_system/cli/commands.rb, line 75 def remove(args = []) manifest = load_manifest(args) platform = GeneSystem::Platform.new manifest.steps.each do |step| platform.execute_commands(step.remove.cmd) end GeneSystem::CLI.print_message("\nmanifest successfully removed") end
Private Class Methods
load_manifest(args)
click to toggle source
# File lib/gene_system/cli/commands.rb, line 88 def load_manifest(args) manifest_rel = args.shift raise 'no manifest path provided' unless manifest_rel manifest_path = File.join(Dir.pwd, manifest_rel) unless File.exist?(manifest_path) raise "cannot find manifest at #{manifest_path}" end GeneSystem::Manifest.new_from_file(manifest_path) end
skip?(step, platform)
click to toggle source
# File lib/gene_system/cli/commands.rb, line 101 def skip?(step, platform) return false if step.install.skip.nil? platform.execute_command(step.install.skip).zero? end