Skip to content

Add choice type #114

@stdweird

Description

@stdweird

The choice type determines if a string is in a list of possible choices (name from to the python optparse choice option). This would replace the current heavy usage of string with match(SELF, '^(a|b|c)$') with

    "attr" ? choice('a', 'b', 'c')

String as a basetype is the most common one (or even only one). makes no sense for boolean i think, and long already has long(1..4) which is something similar. so only float is not covered, which i think is acceptable.

Related to quattor/template-library-core#102

To be implemented via one of

  • make a new type buitin that does this (we can use function to check type #95 in case someone wants the choice to be usabel via a function function is_choice = {is_type(choice, ARGV);}
  • a new builtin is_choice and we can make a pantype type choice = string[] with is_choice(SELF)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions