Class: Toys::Completion::Context
- Inherits:
-
Object
- Object
- Toys::Completion::Context
- Defined in:
- core-docs/toys/completion.rb
Overview
Defined in the toys-core gem
The context in which to determine completion candidates.
Instance Attribute Summary collapse
-
#cli ⇒ Toys::CLI
readonly
The CLI being run.
-
#fragment ⇒ String
readonly
The current string fragment to complete.
-
#fragment_prefix ⇒ String
readonly
A non-completed prefix for the current fragment.
-
#previous_words ⇒ Array<String>
readonly
All previous words.
Instance Method Summary collapse
-
#[](key) ⇒ Object
(also: #get)
Get data for arbitrary key.
-
#arg_parser ⇒ Toys::ArgParser
Current ArgParser indicating the status of argument parsing up to this point.
-
#args ⇒ Array<String>
An array of complete arguments passed to the tool, prior to the fragment to complete.
-
#initialize(cli:, previous_words: [], fragment_prefix: "", fragment: "", **params) ⇒ Context
constructor
Create a completion context.
-
#tool ⇒ Toys::ToolDefinition
The tool being invoked, which should control the completion.
-
#with(**delta_params) ⇒ Toys::Completion::Context
Create a new completion context with the given modifications.
Constructor Details
#initialize(cli:, previous_words: [], fragment_prefix: "", fragment: "", **params) ⇒ Context
Create a completion context
32 33 34 |
# File 'core-docs/toys/completion.rb', line 32 def initialize(cli:, previous_words: [], fragment_prefix: "", fragment: "", **params) # Source available in the toys-core gem end |
Instance Attribute Details
#cli ⇒ Toys::CLI (readonly)
The CLI being run.
50 51 52 |
# File 'core-docs/toys/completion.rb', line 50 def cli @cli end |
#fragment ⇒ String (readonly)
The current string fragment to complete
68 69 70 |
# File 'core-docs/toys/completion.rb', line 68 def fragment @fragment end |
#fragment_prefix ⇒ String (readonly)
A non-completed prefix for the current fragment.
62 63 64 |
# File 'core-docs/toys/completion.rb', line 62 def fragment_prefix @fragment_prefix end |
#previous_words ⇒ Array<String> (readonly)
All previous words.
56 57 58 |
# File 'core-docs/toys/completion.rb', line 56 def previous_words @previous_words end |
Instance Method Details
#[](key) ⇒ Object Also known as: get
Get data for arbitrary key.
75 76 77 |
# File 'core-docs/toys/completion.rb', line 75 def [](key) # Source available in the toys-core gem end |
#arg_parser ⇒ Toys::ArgParser
Current ArgParser indicating the status of argument parsing up to this point.
103 104 105 |
# File 'core-docs/toys/completion.rb', line 103 def arg_parser # Source available in the toys-core gem end |
#args ⇒ Array<String>
An array of complete arguments passed to the tool, prior to the fragment to complete.
93 94 95 |
# File 'core-docs/toys/completion.rb', line 93 def args # Source available in the toys-core gem end |
#tool ⇒ Toys::ToolDefinition
The tool being invoked, which should control the completion.
84 85 86 |
# File 'core-docs/toys/completion.rb', line 84 def tool # Source available in the toys-core gem end |
#with(**delta_params) ⇒ Toys::Completion::Context
Create a new completion context with the given modifications.
42 43 44 |
# File 'core-docs/toys/completion.rb', line 42 def with(**delta_params) # Source available in the toys-core gem end |