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

Get the expanded string of entire command executed even if entered string is partial #65

Closed
DeekshaBhandary opened this issue Sep 13, 2021 · 5 comments
Labels

Comments

@DeekshaBhandary
Copy link

cli> show list1 ?
value1
data1
string1
cli> show list1 s  <Enter>

cv_string_get(cvec_i(cvv, 0)); this method returns "show list1 s" instead of "show list1 string1" in the above case
Should be able to retrieve the entire string

@olofhagsand
Copy link
Member

I am not sure. If you inspect the cvv argument, you see the following:

(gdb) p cvec_print(stderr,cvv)
0 : cmd = show list1 s
1 : show = "show"
2 : list1 = "list1"
3 : string1 = "string1"

The first argument is the string as entered by the user. Since the user entered "s", that is returned.
If you want the third argument, you can get it via cv_string_get(cvec_i(cvv,3)) in that example.

One can also construct a string from the argv[1]..argv[3] that corresponds to the string you need.

olofhagsand added a commit that referenced this issue Oct 21, 2021
@olofhagsand olofhagsand added feature Feature request Please verify and removed question labels Oct 21, 2021
olofhagsand added a commit that referenced this issue Oct 21, 2021
@olofhagsand
Copy link
Member

Added a replacement of the cvv[0] cmd parameter from the original string to the expanded string.
However it turned out the expanded string depended on excludekeys settings and needed to be reverted.
Need somewhat larger take and will have to wait.

olofhagsand added a commit that referenced this issue Oct 31, 2021
  * See cligen_tutorial Section 6.1
  * Moved cv_exclude_keys() to cligen_exclude_keys_set() and created cvec_exclude_keys()
  * New: cligen_expand_first_get/set() and cvec_expand_first()
  * Merged the use of cvv and cvvall parameters into a single cvv parameter in match_pattern code
  * Solved [Get the expanded string of entire command executed even if entered string is partial](#65)
@olofhagsand
Copy link
Member

There is now a solution to this issue.
To get the behavior requested in this ticket, you need to call: cligen_expand_first_set(h,1)
Please see also cligen_tutorial Section 6.1
Please verify the solution

@olofhagsand
Copy link
Member

To clarify, to test it, you need to initialize it properly, such as call cligen_expand_first_set(cli_cligen(h), 1) at some point in main() in apps/cli/cli_main.c and recompile. No specific config option is added yet.

@DeekshaBhandary
Copy link
Author

Issue has been fixed.

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