~aleteoryx/tclfeed-bsky

ref: b412dbd9bef8091f139642f647b66b4f02974529 tclfeed-bsky/lib/prompt.tcl -rw-r--r-- 627 bytes
b412dbd9Aleteoryx publisher 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"
}