Class: CliShim

Inherits:
HasOutAndLog show all
Defined in:
lib/nu/cli_shim.rb

Instance Method Summary collapse

Methods inherited from HasOutAndLog

#initialize

Constructor Details

This class inherits a constructor from HasOutAndLog

Instance Method Details

#get_setting(name) ⇒ Object



21
22
23
# File 'lib/nu/cli_shim.rb', line 21

def get_setting(name)
	out "#{name} = #{Nu::Api.get_setting(name)}"
end

#install_package(package, package_version) ⇒ Object



17
18
19
# File 'lib/nu/cli_shim.rb', line 17

def install_package(package, package_version)
	Nu::Api.install_package(package, package_version)
end

#propose(name, version) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nu/cli_shim.rb', line 25

def propose(name, version)
	log "Propose called. name: #{name} version: #{version}"
	report(true)
	out "Analyzing effects of installing #{name}..."
	results = Nu::Api.propose_package(name, version)
	
	if results.conflict?
		out "A conflict is detected between #{name} \nand the currently installed:"
		hr
		results.conflicts.each{|spec| out "    #{spec[:name]} (#{spec[:requirement_one].requirements.first}) vs. (#{spec[:requirement_two].requirements.first})"}
		hr("\n")
	else
		out "No unresolved conflicts. \nAdding #{name} would result in:"
		hr
		results.suggested_packages.each{|spec| out "    #{spec[:name]} (#{spec[:version]})"}
		hr("\n")
	end
end

#report(details = false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/nu/cli_shim.rb', line 6

def report(details=false)
	log "Report called."
	
	out "\n"
	out "The following packages are installed:"
	hr
	#TODO: render differently if details==true
	Nu::Api.report.each{|i| out "    #{i.name} (#{i.version})"}
	hr("\n")
end