Class: Toys::Completion::Context

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(cli:, previous_words: [], fragment_prefix: "", fragment: "", **params) ⇒ Context

Create a completion context.

Extra params are optional and can be used to affect the behavior in specific cases. Currently these are:

  • shell: :bash causes the FileSystem completion to include glob expansions, since bash doesn't handle those directly
  • disable_flags: true causes tool completion to omit flag completions which is used by the toys do built-in tool

Parameters:

  • cli (Toys::CLI)

    The CLI being run. Required.

  • previous_words (Array<String>) (defaults to: [])

    Array of complete strings that appeared prior to the fragment to complete.

  • fragment_prefix (String) (defaults to: "")

    A prefix in the fragment that does not participate in completion. (e.g. "key=")

  • fragment (String) (defaults to: "")

    The string fragment to complete.

  • params (Hash)

    Miscellaneous context data



40
41
42
# File 'core-docs/toys/completion.rb', line 40

def initialize(cli:, previous_words: [], fragment_prefix: "", fragment: "", **params)
  # Source available in the toys-core gem
end

Instance Attribute Details

#cliToys::CLI (readonly)

The CLI being run.

Returns:



58
59
60
# File 'core-docs/toys/completion.rb', line 58

def cli
  @cli
end

#fragmentString (readonly)

The current string fragment to complete

Returns:

  • (String)


76
77
78
# File 'core-docs/toys/completion.rb', line 76

def fragment
  @fragment
end

#fragment_prefixString (readonly)

A non-completed prefix for the current fragment.

Returns:

  • (String)


70
71
72
# File 'core-docs/toys/completion.rb', line 70

def fragment_prefix
  @fragment_prefix
end

#previous_wordsArray<String> (readonly)

All previous words.

Returns:

  • (Array<String>)


64
65
66
# File 'core-docs/toys/completion.rb', line 64

def previous_words
  @previous_words
end

Instance Method Details

#[](key) ⇒ Object Also known as: get

Get data for arbitrary key.

Parameters:

  • key (Symbol)

Returns:

  • (Object)


83
84
85
# File 'core-docs/toys/completion.rb', line 83

def [](key)
  # Source available in the toys-core gem
end

#arg_parserToys::ArgParser

Current ArgParser indicating the status of argument parsing up to this point.

Returns:



111
112
113
# File 'core-docs/toys/completion.rb', line 111

def arg_parser
  # Source available in the toys-core gem
end

#argsArray<String>

An array of complete arguments passed to the tool, prior to the fragment to complete.

Returns:

  • (Array<String>)


101
102
103
# File 'core-docs/toys/completion.rb', line 101

def args
  # Source available in the toys-core gem
end

#toolToys::ToolDefinition

The tool being invoked, which should control the completion.



92
93
94
# File 'core-docs/toys/completion.rb', line 92

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.

Parameters:

  • delta_params (Hash)

    Replace context data.

Returns:



50
51
52
# File 'core-docs/toys/completion.rb', line 50

def with(**delta_params)
  # Source available in the toys-core gem
end