Module: Carson::Runtime::Status

Included in:
Carson::Runtime
Defined in:
lib/carson/runtime/status.rb

Instance Method Summary collapse

Instance Method Details

#status!(json_output: false) ⇒ Object

Entry point for ‘carson status`.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/carson/runtime/status.rb', line 6

def status!( json_output: false )
	data = gather_status

	if json_output
		output.puts JSON.pretty_generate( data )
	else
		print_status( data: data )
	end

	EXIT_OK
end

#status_all!(json_output: false) ⇒ Object

Portfolio-wide status overview across all governed repositories.



19
20
21
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
49
50
# File 'lib/carson/runtime/status.rb', line 19

def status_all!( json_output: false )
	repositories = config.govern_repos
	if repositories.empty?
		puts_line "No governed repositories configured."
		puts_line "  Run carson onboard in each repo to register."
		return EXIT_ERROR
	end

	results = repositories.map do |repo_path|
		repo_name = File.basename( repo_path )
		unless Dir.exist?( repo_path )
			{ name: repo_name, status: "error", error: "not found" }
		else
			begin
				scoped_runtime = build_scoped_runtime( repo_path: repo_path )
				{ name: repo_name, status: "ok" }.merge( scoped_runtime.send( :gather_status ) )
			rescue StandardError => exception
				{ name: repo_name, status: "error", error: exception.message }
			end
		end
	end

	if json_output
		output.puts JSON.pretty_generate( { command: "status", repos: results, repositories: results } )
	else
		puts_line "Carson #{Carson::VERSION} — Portfolio (#{repositories.length} repo#{plural_suffix( count: repositories.length )})"
		puts_line ""
		results.each { |result| print_portfolio_status( result: result ) }
	end

	EXIT_OK
end