Module: GithubCLI::Manpage

Extended by:
Manpage
Included in:
Manpage
Defined in:
lib/github_cli/manpage.rb

Constant Summary collapse

MANPAGES =
%w[
  gcli-authorize.1
  gcli-config.1
  gcli-repo.1
  gcli.1
  gcli-whoami.1
]

Instance Method Summary collapse

Instance Method Details

#groffObject

The groff command with extra arguments to turn roff into terminal output



21
22
23
# File 'lib/github_cli/manpage.rb', line 21

def groff
  "groff -Wall -mtty-char -mandoc -Tascii"
end

#has?(command) {|_self| ... } ⇒ Boolean

Yields:

  • (_self)

Yield Parameters:

Returns:

  • (Boolean)


15
16
17
# File 'lib/github_cli/manpage.rb', line 15

def has?(command)
  yield self if MANPAGES.include? command
end

#has_groff?Boolean

Check if groff is installed on the system

Returns:

  • (Boolean)


26
27
28
# File 'lib/github_cli/manpage.rb', line 26

def has_groff?
  System.command? 'groff'
end

#has_man?Boolean

Check if man is installed on the system

Returns:

  • (Boolean)


31
32
33
# File 'lib/github_cli/manpage.rb', line 31

def has_man?
  System.command? 'man'
end

#show(command) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/github_cli/manpage.rb', line 35

def show(command)
  root = File.expand_path("../man", __FILE__)

  if has_groff?
    system "#{groff} #{root}/#{command} | #{Pager.pager_command}"
  else
    system "#{Pager.pager_command} #{root}/#{command}.txt"
  end
end