Class: Toys::StandardMiddleware::SetDefaultDescriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/toys/standard_middleware/set_default_descriptions.rb

Overview

This middleware sets default description fields for tools and command line arguments and flags that do not have them set otherwise.

You can modify the static descriptions for tools, namespaces, and the root tool by passing parameters to this middleware. For finer control, you can override methods to modify the description generation logic.

Constant Summary collapse

DEFAULT_TOOL_DESC =

The default description for tools.

Returns:

  • (String)
"(No tool description available)"
DEFAULT_DELEGATE_DESC =

The default description for delegating tools.

Returns:

  • (String)
'(Delegates to "%<target>s")'
DEFAULT_NAMESPACE_DESC =

The default description for namespaces.

Returns:

  • (String)
"(A namespace of tools)"
DEFAULT_ROOT_DESC =

The default description for the root tool.

Returns:

  • (String)
"Command line tool built using the toys-core gem."
DEFAULT_ROOT_LONG_DESC =

The default long description for the root tool.

Returns:

  • (String)
[
  "This command line tool was built using the toys-core gem. See" \
    " https://dazuma.github.io/toys/gems/toys-core for more info.",
  "To replace this message, set the description and long description" \
    " of the root tool, or configure the SetDefaultDescriptions" \
    " middleware.",
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(default_tool_desc: DEFAULT_TOOL_DESC, default_tool_long_desc: nil, default_namespace_desc: DEFAULT_NAMESPACE_DESC, default_namespace_long_desc: nil, default_root_desc: DEFAULT_ROOT_DESC, default_root_long_desc: DEFAULT_ROOT_LONG_DESC, default_delegate_desc: DEFAULT_DELEGATE_DESC) ⇒ SetDefaultDescriptions

Create a SetDefaultDescriptions middleware given default descriptions.

Parameters:

  • default_tool_desc (String, nil) (defaults to: DEFAULT_TOOL_DESC)

    The default short description for runnable tools, or nil not to set one. Defaults to DEFAULT_TOOL_DESC.

  • default_tool_long_desc (Array<String>, nil) (defaults to: nil)

    The default long description for runnable tools, or nil not to set one. Defaults to nil.

  • default_namespace_desc (String, nil) (defaults to: DEFAULT_NAMESPACE_DESC)

    The default short description for non-runnable tools, or nil not to set one. Defaults to DEFAULT_TOOL_DESC.

  • default_namespace_long_desc (Array<String>, nil) (defaults to: nil)

    The default long description for non-runnable tools, or nil not to set one. Defaults to nil.

  • default_root_desc (String, nil) (defaults to: DEFAULT_ROOT_DESC)

    The default short description for the root tool, or nil not to set one. Defaults to DEFAULT_ROOT_DESC.

  • default_root_long_desc (Array<String>, nil) (defaults to: DEFAULT_ROOT_LONG_DESC)

    The default long description for the root tool, or nil not to set one. Defaults to DEFAULT_ROOT_LONG_DESC.

  • default_delegate_desc (String, nil) (defaults to: DEFAULT_DELEGATE_DESC)

    The default short description for delegate tools, or nil not to set one. May include an sprintf field for the target name. Defaults to DEFAULT_DELEGATE_DESC.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/toys/standard_middleware/set_default_descriptions.rb', line 75

def initialize(default_tool_desc: DEFAULT_TOOL_DESC,
               default_tool_long_desc: nil,
               default_namespace_desc: DEFAULT_NAMESPACE_DESC,
               default_namespace_long_desc: nil,
               default_root_desc: DEFAULT_ROOT_DESC,
               default_root_long_desc: DEFAULT_ROOT_LONG_DESC,
               default_delegate_desc: DEFAULT_DELEGATE_DESC)
  @default_tool_desc = default_tool_desc
  @default_tool_long_desc = default_tool_long_desc
  @default_namespace_desc = default_namespace_desc
  @default_namespace_long_desc = default_namespace_long_desc
  @default_root_desc = default_root_desc
  @default_root_long_desc = default_root_long_desc
  @default_delegate_desc = default_delegate_desc
end