Module: GithubCLI::Manpage

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

Constant Summary collapse

MANPAGES =
%w[
  gcli-config.1
]

Instance Method Summary collapse

Instance Method Details

#groffObject

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



17
18
19
# File 'lib/github_cli/manpage.rb', line 17

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

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

Yields:

  • (_self)

Yield Parameters:

Returns:

  • (Boolean)


11
12
13
# File 'lib/github_cli/manpage.rb', line 11

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

#has_groff?Boolean

Check if groff is installed on the system

Returns:

  • (Boolean)


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

def has_groff?
  System.command? 'groff'
end

#has_man?Boolean

Check if man is installed on the system

Returns:

  • (Boolean)


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

def has_man?
  System.command? 'man'
end

#show(command) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/github_cli/manpage.rb', line 31

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