yanglint FEATURE hints for option arguments
... and also completion if prefix is also specified.
diff --git a/tools/lint/tests/interactive/completion.test b/tools/lint/tests/interactive/completion.test
index 633fabb..86ded1f 100644
--- a/tools/lint/tests/interactive/completion.test
+++ b/tools/lint/tests/interactive/completion.test
@@ -1,5 +1,7 @@
source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
+set mdir "$::env(YANG_MODULES_DIR)"
+
variable ly_cleanup {
ly_ignore
ly_exit
@@ -7,7 +9,7 @@
test completion_hints_ietf_ip {Completion and hints for ietf-ip.yang} {
-setup $ly_setup -cleanup $ly_cleanup -body {
- ly_cmd "add $::env(YANG_MODULES_DIR)/ietf-ip.yang"
+ ly_cmd "add $mdir/ietf-ip.yang"
# completion and hint
ly_completion "print -f info -P " "print -f info -P /ietf-"
@@ -41,4 +43,27 @@
ly_completion "/e" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled "
}}
+# Note that somehow a command is automatically sent again (\t\t replaced by \r) after the hints.
+# But that doesn't affect the test because the tests only focus on the word in the hint.
+
+test hint_data_file {Show file hints for command data} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data $mdir\t\t" "data $mdir" "modleaf.yang.*"
+}}
+
+test hint_data_format {Show print hints for command data --format} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data -f \t\t" "data -f " "xml.*"
+}}
+
+test hint_data_file_after_opt {Show file hints after option with argument} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data -f xml $mdir\t\t" "data -f xml $mdir" "modleaf.yang.*"
+}}
+
+test hint_data_file_after_opt2 {Show file hints after option without argument} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_hint "data -m $mdir\t\t" "data -m $mdir" "modleaf.yang.*"
+}}
+
cleanupTests
diff --git a/tools/lint/tests/interactive/ly.tcl b/tools/lint/tests/interactive/ly.tcl
index 8386848..3fa2c82 100644
--- a/tools/lint/tests/interactive/ly.tcl
+++ b/tools/lint/tests/interactive/ly.tcl
@@ -165,7 +165,7 @@
send -- "${input}\t"
# expecting the hints, previous input from which the hints were generated
# and some number of terminal control characters
- expect -re "^\r\n${output}\r> ${prev_input}.*\r.*$"
+ expect -re "${output}\r> ${prev_input}.*\r.*$"
}
# Send 'exit' and wait for eof.