Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choice with space is not working in CLIgen code: #24

Closed
ashuagarwal01 opened this issue May 1, 2019 · 5 comments
Closed

Choice with space is not working in CLIgen code: #24

ashuagarwal01 opened this issue May 1, 2019 · 5 comments
Labels

Comments

@ashuagarwal01
Copy link

Choice with a space is not parsed by Cligen code.

Example:

  1. choice ("Choice example") <string choice:unknown|NoSpace|with\ space>, fn_cb(); -->not working
  2. choice ("Choice example") <string choice:unknown|NoSpace|”with space”>, fn_cb(); -->not working

As per yang RFC, space is a valid character in choice type.

Please note: Auto-complete work for first case, but when you press enter, it will say invalid token.

@olofhagsand olofhagsand added the bug label May 3, 2019
@olofhagsand
Copy link
Member

Yes. Space is not allowed in CLIgen choice type.
I would like to understand the use-case better (to be able to come up with a solution):

  • In what example do you need identifiers with space?
  • Do you use generated Yang/CLIgen code?
  • If so, Yang choice is different from CLIgen choice, Yang enumeration and some others are generated into CLIgen choice, but not Yang choice (which is generated into {case1; case2;} )

@ashuagarwal01
Copy link
Author

Yang Enumeration is considered as choice in Cligen as per my understanding.
https://tools.ietf.org/html/rfc6020#section-9.6.4 explain that space is valid keyword in enum.

I am taking an example of Clixon. I modified example.yang in clixon as below:

/* Translation function example - See also example_cli */
list translate{
    leaf value{
        type uint32 {
          range "2..max";
        }
    }
    leaf port {
      type enumeration
      {
        enum unknown;
        enum without-space;
        enum "with space";
      }
    }
}

The clixon_cli parse this yang as :

translate{
value (<value:uint32 range[2:4294967295]>|<value:uint32 expand_dbvar("candidate","/translate/value")>),overwrite_me("/translate/value");
port <port:string choice:unknown|without-space|with space>,overwrite_me("/translate/port");
}

Which is incorrect and failing the clixon_cli parsing.

olofhagsand added a commit to clicon/clixon that referenced this issue May 15, 2019
…, see [Choice with space is not working in CLIgen code](clicon/cligen#24)
@olofhagsand
Copy link
Member

This should now work using backslash escape code, eg:
choice with\ space
please verify

@ashuagarwal01
Copy link
Author

Patch is working as expected.
Thanks for the fix.

@olofhagsand
Copy link
Member

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants