Module: CommandKit::Help::Man
- Extended by:
- ModuleMethods
- Includes:
- CommandName, CommandKit::Help, Stdio
- Defined in:
- lib/command_kit/help/man.rb
Overview
Allows displaying a man-page instead of the usual --help
output.
Examples
class Foo < CommandKit::Command
include CommandKit::Help::Man
man_dir "#{__dir__}/../../man"
end
Defined Under Namespace
Modules: ClassMethods, ModuleMethods
Instance Attribute Summary
Attributes included from CommandName
Instance Method Summary collapse
- #help ⇒ Object
-
#help_man(man_page = self.class.man_page) ⇒ Boolean?
Provides help information by showing one of the man pages within .man_dir.
-
#man(page, section: nil) ⇒ Boolean?
Displays the given man page.
Methods included from ModuleMethods
Methods included from Stdio
#abort, #gets, #initialize, #print, #printf, #putc, #puts, #readline, #readlines, #stderr, #stdin, #stdout
Methods included from ModuleMethods
Methods included from CommandName
Methods included from CommandName::ModuleMethods
Instance Method Details
#help ⇒ Object
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/command_kit/help/man.rb', line 161 def help if stdout.tty? if help_man.nil? # the `man` command is not installed super end else super end end |
#help_man(man_page = self.class.man_page) ⇒ Boolean?
Provides help information by showing one of the man pages within .man_dir.
138 139 140 141 142 143 144 145 146 |
# File 'lib/command_kit/help/man.rb', line 138 def help_man(man_page=self.class.man_page) unless self.class.man_dir raise(NotImplementedError,"#{self.class}.man_dir not set") end man_path = File.join(self.class.man_dir,man_page) man(man_path) end |
#man(page, section: nil) ⇒ Boolean?
Displays the given man page.
114 115 116 117 118 119 120 |
# File 'lib/command_kit/help/man.rb', line 114 def man(page, section: nil) if section system('man',section.to_s,page.to_s) else system('man',page.to_s) end end |