Page MenuHomeVyOS Platform

Use Literal types to provide op-mode CLI choices and API enums
Closed, ResolvedPublicFEATURE REQUEST

Description

Use of typing.Literal in standardized op-mode scripts provides arpgparse 'choices' for the CLI script and enum types for the API.

For example, adding:

ArgFamily = typing.Literal["inet", "inet6"]
...
def show(raw: bool,
         family: ArgFamily,
...

to op-mode/route.py, may be used by opmode.py, respectively, schema_from_op_mode.py to provide:

root@vyos:/usr/libexec/vyos/op_mode# ./route.py show -h
usage: route.py show [-h] [--raw] --family  {inet,inet6} ...

respectively:

enum FamilyRoute {
    inet
    inet6
}

input ShowRouteInput {
    key: String
    family: FamilyRoute!
    net: String = null
    table: Int = null
    protocol: String = null
    vrf: String = null
    tag: String = null
...

Details

Version
vyos-1.4
Is it a breaking change?
Perfectly compatible
Issue type
Feature (new functionality)

Event Timeline

jestabro changed the task status from Open to In progress.
jestabro triaged this task as Normal priority.
jestabro created this object in space S1 VyOS Public.
jestabro moved this task from Open to Finished on the VyOS 1.4 Sagitta board.