Class: Toys::StandardMiddleware::ShowHelp
- Inherits:
-
Object
- Object
- Toys::StandardMiddleware::ShowHelp
- 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, separate_sources: false, use_less: false, stream: $stdout, styled_output: nil) ⇒ ShowHelp
constructor
Create a ShowHelp middleware.
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, separate_sources: false, use_less: false, stream: $stdout, styled_output: nil) ⇒ ShowHelp
Create a ShowHelp middleware.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/toys/standard_middleware/show_help.rb', line 171 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, separate_sources: 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 @separate_sources = separate_sources @stream = stream @styled_output = styled_output @use_less = use_less && !Compat.jruby? end |