~aleteoryx/tclfeed-bsky

ref: 951aa944b42e9c60684dae9e7355486582f1cff6 tclfeed-bsky/lib/prompt.tcl -rw-r--r-- 627 bytes
951aa944Aleteoryx add lists, make blocker prettier 29 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
proc input {message varname {default {}}} {
  upvar $varname input
  set input {}
  puts $message
  while {$input == {}} {
    puts -nonewline "% "
    flush stdout
    gets stdin input
    if {$input == {}} {set input $default}
  }
  puts ""
}

proc inopt {message varname} {
  upvar $varname input
  set input {}
  puts $message
  puts -nonewline "% "
  flush stdout
  gets stdin input
  puts ""
}

proc paswd {message varname} {
  upvar $varname input
  set input {}
  puts $message
  exec stty -echo
  while {$input == {}} {
    puts -nonewline "% "
    flush stdout
    gets stdin input
  }
  exec stty echo
  puts "\n"
}