Sha256: 2dbc50cb880254821228036a85cf473250946d159ac64b25188c8f2a35848bcf
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
# encoding: utf-8 module GithubCLI # Responsible for display and size detection. class Terminal DEFAULT_WIDTH = 120 DEFAULT_HEIGHT = 40 class << self attr_accessor :size def render_output(response, options={}) render_status response case options[:format].to_s when 'table' formatter = Formatters::Table.new(response) formatter.format when 'csv' formatter = Formatters::CSV.new(response) formatter.format when 'json' 'json output' else raise UnknownFormatError, options[:format] end end # Render status code def render_status(response) puts "Response Status: #{response.status}" puts end def render_header end def print_commands(pattern=nil) GithubCLI.ui.info "Commands:" commands = Command.all.select do |cmd| cmd if pattern && cmd.namespace =~ pattern end.map do |cmd| build_command cmd end if !commands.empty? GithubCLI.ui.print_table commands, :truncate => true else print_command_not_found pattern.to_s.gsub(/\W|/, '')[3..-1] end end def build_command(cmd, indent=3) prefix = " " * indent if cmd.namespace.empty? ["#{prefix + cmd.usage}", cmd.desc] else ["#{prefix + cmd.namespace} #{cmd.usage}", cmd.desc] end end def print_command_not_found(cmd) GithubCLI.ui.info "ghc: '#{cmd}' is not a ghc command. See 'ghc --help'." end def print_program_name(print=true) GithubCLI.ui.info <<-TEXT #{GithubCLI.program_name} TEXT end def print_usage(print=true) if print GithubCLI.ui.info <<-TEXT Usage: ghc <command> <subcommand> [<args>] TEXT end end end end # Terminal end # GithubCLI
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
github_cli-0.3.1 | lib/github_cli/terminal.rb |