Class: Teapot::Command::Top

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/teapot/command.rb

Instance Method Summary collapse

Instance Method Details

#configurationObject



97
98
99
# File 'lib/teapot/command.rb', line 97

def configuration
	@options[:configuration]
end

#context(root = self.root) ⇒ Object



101
102
103
# File 'lib/teapot/command.rb', line 101

def context(root = self.root)
	Context.new(root, configuration: configuration)
end

#invoke(program_name: File.basename($0)) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/teapot/command.rb', line 105

def invoke(program_name: File.basename($0))
	if @options[:version]
		puts "teapot v#{Teapot::VERSION}"
	elsif @options[:help] or @command.nil?
		print_usage(program_name)
	else
		track_time do
			@command.invoke(self)
		end
	end
end

#loggerObject



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/teapot/command.rb', line 83

def logger
	@logger ||= Logger.new($stderr).tap do |logger|
		logger.formatter = ::Build::CompactFormatter.new(verbose: verbose?)
		
		if verbose?
			logger.level = Logger::DEBUG
		elsif quiet?
			logger.level = Logger::WARN
		else
			logger.level = Logger::INFO
		end
	end
end

#quiet?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/teapot/command.rb', line 79

def quiet?
	@options[:logging] == :quiet
end

#rootObject



71
72
73
# File 'lib/teapot/command.rb', line 71

def root
	::Build::Files::Path.expand(@options[:root] || Dir.getwd)
end

#verbose?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/teapot/command.rb', line 75

def verbose?
	@options[:logging] == :verbose
end