AnyStringToken

zio.cli.completion.RegularLanguage.AnyStringToken
case object AnyStringToken extends Token

AnyStringToken represents the set of all strings. For tab completion purposes, this is used to represent the name of the executable. (It may be aliased or renamed to be different than Command.Single.name.)

Attributes

Graph
Supertypes
trait Singleton
trait Product
trait Mirror
trait Token
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type

Members list

Type members

Inherited types

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Singleton

Attributes

Inherited from:
Singleton
type MirroredMonoType = Singleton.this.type

The mirrored *-type

The mirrored *-type

Attributes

Inherited from:
Singleton
type MirroredType = Singleton.this.type

Attributes

Inherited from:
Singleton

Inherited and Abstract types

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def derive(token: String, cliConfig: CliConfig): UIO[RegularLanguage]

Calculate the Brzozowski derivative of this language with respect to the given string. This is an effectful function because it can call PrimType.validate (e.g., when validating file paths, etc.).

Calculate the Brzozowski derivative of this language with respect to the given string. This is an effectful function because it can call PrimType.validate (e.g., when validating file paths, etc.).

Value parameters

token

The string to use for calculation of the Brzozowski derivative.

Attributes

Returns

Brzozowski derivative wrapped in an UIO instance.

def firstTokens(prefix: String, compgen: Compgen): UIO[Set[String]]

Returns a set consisting of the first token of all strings in this language that are useful for CLI tab completion. For infinite or unwieldly languages, it is perfectly fine to return the empty set: This will simply not display any completions to the user.

Returns a set consisting of the first token of all strings in this language that are useful for CLI tab completion. For infinite or unwieldly languages, it is perfectly fine to return the empty set: This will simply not display any completions to the user.

If you'd like the cursor to advance to the next word when tab completion unambiguously matches the prefix to a token, append a space (" ") character to the end of the returned token. Otherwise, the cursor will skip to the end of the completed token in the terminal.

Some examples of different use cases:

  1. Completing file/directory names:
    • Append a space to the ends of file names (e.g., "bippy.pdf"). This is because we want the cursor to jump to the next argument position if tab completion unambiguously succeeds.
  • Do not append a space to the end of a directory name (e.g., "foo/"). This is because we want the user to be able to press tab again to gradually complete a lengthy file path.
  • Append a space to the ends of string tokens.

You may be asking why we don't try to use the -o nospace setting of compgen and complete. The answer is they appear to be all or nothing: For a given tab completion execution, you have to choose one behavior or the other. This does not work well when completing both file names and directory names at the same time.

Attributes

Inherited methods

Attributes

Inherited from:
RegularLanguage
def ?: Alt

Attributes

Inherited from:
RegularLanguage
def contains(tokens: List[String], cliConfig: CliConfig): UIO[Boolean]

Checks to see if the input token list is a member of the language.

Checks to see if the input token list is a member of the language.

Attributes

Returns

true if and only if tokens is in the language.

Inherited from:
RegularLanguage

Create a new instance of type T with elements taken from product p.

Create a new instance of type T with elements taken from product p.

Attributes

Inherited from:
Singleton

This is the delta (δ) predicate from "Parsing With Derivatives", indicating whether this language contains the empty string.

This is the delta (δ) predicate from "Parsing With Derivatives", indicating whether this language contains the empty string.

Attributes

Returns

true if and only if this language contains the empty string.

Inherited from:
Token

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
def rep(min: Option[Int], max: Option[Int]): RegularLanguage

Attributes

Inherited from:
RegularLanguage
def |(other: String): RegularLanguage

Attributes

Inherited from:
RegularLanguage

Attributes

Inherited from:
RegularLanguage
def ~(other: String): RegularLanguage

Attributes

Inherited from:
RegularLanguage

Attributes

Inherited from:
RegularLanguage