Module: CommandKit::Help::Man
- Extended by:
- ModuleMethods
- Includes:
- CommandName, CommandKit::Help, Man, 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.
Methods included from ModuleMethods
Methods included from Man
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
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/command_kit/help/man.rb', line 137 def help if stdout.tty? if self.class.man_dir status = help_man if status.nil? # the `man` command is not installed super end else # man_dir was not set super end else # stdout is not a TTY 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.
117 118 119 120 121 122 123 124 125 |
# File 'lib/command_kit/help/man.rb', line 117 def help_man(man_page=self.class.man_page) unless self.class.man_dir raise(NotImplementedError,"man_dir was not set in #{self.class}") end man_path = File.join(self.class.man_dir,man_page) man(man_path) end |