Skip to content

Instantly share code, notes, and snippets.

@adamnew123456
Last active May 24, 2018 12:14
Show Gist options
  • Save adamnew123456/59927331017602be8d668a48baeb2992 to your computer and use it in GitHub Desktop.
Save adamnew123456/59927331017602be8d668a48baeb2992 to your computer and use it in GitHub Desktop.
Test
proc jdbc_command {options} {
set classpath [lindex $options 0]
set commands {/usr/bin/java -classpath}
lappend commands "/home/chris/Source/jdbcnotebook/target/server-1.0-SNAPSHOT-jar-with-dependencies.jar:$classpath"
lappend commands {*}[lrange $options 1 end]
return $commands
}
proc ado_command {options} {
set commands {/usr/bin/mono /home/chris/Source/adonotebook/ADONotebook.Server/bin/Debug/Server.exe}
lappend commands {*}$options
return $commands
}
set connections {
Northwind-ADO
{ado -p 1995 -f Mono.Data.Sqlite "Data Source=/home/chris/Northwind_small.sqlite"}
Northwind-JDBC
{jdbc ":/home/chris/Source/jdbcnotebook/sqlite-jdbc-3.21.0.jar" -p 1996 -j org.sqlite.JDBC "jdbc:sqlite:/home/chris/Northwind_small.sqlite"}
}
source "~/.notebooks.tcl"
foreach {name command} $connections {
set command_array($name) $command
puts "($name) $command"
}
proc is_valid_choice {name} {
global command_array
return [info exists command_array($name)]
}
set current_choice {xxx}
while {![is_valid_choice $current_choice]} {
puts -nonewline "> "
flush stdout
set current_choice [gets stdin]
}
set command_info $command_array($current_choice)
set command [lindex $command_info 0]
set args [lrange $command_info 1 end]
puts "$command ($current_choice): $args"
set exec_line [${command}_command $args]
exec {*}$exec_line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment