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

Difficulty level
Normal (likely a few hours)
Version
vyos-1.4
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible
Issue type
Feature (new functionality)