Class: Toys::StandardMiddleware::ShowHelp
- Inherits:
-
Object
- Object
- Toys::StandardMiddleware::ShowHelp
- Includes:
- Middleware
- Defined in:
- lib/toys/standard_middleware/show_help.rb
Overview
A middleware that shows help text for the tool when a flag (typically
--help) is provided. It can also be configured to show help by
default if the tool is a namespace that is not runnable.
If a tool is not runnable, this middleware can also add a
--[no-]recursive flag, which, when set to true (the default), shows
all subtools recursively rather than only immediate subtools. This
middleware can also search for keywords in its subtools.
Constant Summary collapse
- DEFAULT_HELP_FLAGS =
Default help flags
["-?", "--help"].freeze
- DEFAULT_USAGE_FLAGS =
Default usage flags
["--usage"].freeze
- DEFAULT_LIST_FLAGS =
Default list subtools flags
["--tools"].freeze
- DEFAULT_RECURSIVE_FLAGS =
Default recursive flags
["-r", "--[no-]recursive"].freeze
- DEFAULT_SEARCH_FLAGS =
Default search flags
["-s WORD", "--search=WORD"].freeze
- DEFAULT_SHOW_ALL_SUBTOOLS_FLAGS =
Default show-all-subtools flags
["--all"].freeze
- SHOW_HELP_KEY =
Key set when the show help flag is present
Object.new.freeze
- SHOW_USAGE_KEY =
Key set when the show usage flag is present
Object.new.freeze
- SHOW_LIST_KEY =
Key set when the show subtool list flag is present
Object.new.freeze
- RECURSIVE_SUBTOOLS_KEY =
Key for the recursive setting
Object.new.freeze
- SEARCH_STRING_KEY =
Key for the search string
Object.new.freeze
- SHOW_ALL_SUBTOOLS_KEY =
Key for the show-all-subtools setting
Object.new.freeze
- TOOL_NAME_KEY =
Key for the tool name
Object.new.freeze
Instance Method Summary collapse
-
#initialize(help_flags: false, usage_flags: false, list_flags: false, recursive_flags: false, search_flags: false, show_all_subtools_flags: false, default_recursive: false, default_show_all_subtools: false, fallback_execution: false, allow_root_args: false, show_source_path: false, use_less: false, stream: $stdout, styled_output: nil) ⇒ ShowHelp
constructor
Create a ShowHelp middleware.
Methods included from Middleware
resolve_specs, spec, spec_from_array
Constructor Details
#initialize(help_flags: false, usage_flags: false, list_flags: false, recursive_flags: false, search_flags: false, show_all_subtools_flags: false, default_recursive: false, default_show_all_subtools: false, fallback_execution: false, allow_root_args: false, show_source_path: false, use_less: false, stream: $stdout, styled_output: nil) ⇒ ShowHelp
Create a ShowHelp middleware.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/toys/standard_middleware/show_help.rb', line 192 def initialize(help_flags: false, usage_flags: false, list_flags: false, recursive_flags: false, search_flags: false, show_all_subtools_flags: false, default_recursive: false, default_show_all_subtools: false, fallback_execution: false, allow_root_args: false, show_source_path: false, use_less: false, stream: $stdout, styled_output: nil) @help_flags = help_flags @usage_flags = usage_flags @list_flags = list_flags @recursive_flags = recursive_flags @search_flags = search_flags @show_all_subtools_flags = show_all_subtools_flags @default_recursive = default_recursive ? true : false @default_show_all_subtools = default_show_all_subtools ? true : false @fallback_execution = fallback_execution @allow_root_args = allow_root_args @show_source_path = show_source_path @stream = stream @styled_output = styled_output @use_less = use_less && !Compat.jruby? end |