diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-05-12 21:23:56 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-05-12 21:23:56 -0400 |
commit | b2ebfdd3bc2a2fc7fead33017ce1a320c6000f40 (patch) | |
tree | ac2783001fa6fb8dc2cd23fe9aeeda6a992e3a63 /blackboard2gradebook.tcl | |
parent | 4406bcb1623be8046b54fed9bf0742156a5671fc (diff) | |
download | GradeBook-b2ebfdd3bc2a2fc7fead33017ce1a320c6000f40.tar.gz GradeBook-b2ebfdd3bc2a2fc7fead33017ce1a320c6000f40.zip |
using cmdline::getopt for better style
Diffstat (limited to 'blackboard2gradebook.tcl')
-rwxr-xr-x | blackboard2gradebook.tcl | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/blackboard2gradebook.tcl b/blackboard2gradebook.tcl index 81e2be4..5bce8e2 100755 --- a/blackboard2gradebook.tcl +++ b/blackboard2gradebook.tcl @@ -4,15 +4,50 @@ exec tclsh "$0" "$@" package require Tcl 8.5 +package require try ;# Tcllib. +package require cmdline 1.5 ;# First version with proper error-codes. package require json::write package require sqlite3 package require md5 source ./GradeBook_lib.tcl -################# Config ############################################ +set options { + {w "Write to database, disabled by default"} +} +set usage " +Usage: + $argv0 \[options] gradebook.sqlitedb blackboard.sqlitedb + + Expect both DB files to be sqilte tables. + Exported DB should have a single table 'export_table' + +Example: + $argv0 2020_Fall_Phys251 blackboard.db + +Options:" + +try { + array set params [::cmdline::getoptions argv $options $usage] + #parray params + + # Note: argv is modified now. The recognized options are + # removed from it, leaving the non-option arguments behind. + if { [llength $argv] < 2 } { + throw {CMDLINE USAGE} [::cmdline::usage $options $usage] + } +} trap {CMDLINE USAGE} {msg o} { + # Trap the usage signal, print the message, and exit the application. + # Note: Other errors are not caught and passed through to higher levels! + puts $msg + exit 1 +} + # if DRYRUN is true the database will not be modified set DRYRUN true +set DRYRUN [expr {!$params(w)}] + +################# Config ############################################ #set categories2export [list FinalExam HomeWork LabReport] set categories2export [list FinalExam] @@ -22,17 +57,6 @@ set infoColumsMarkers {{ - Lateness \(H:M:S\)} { - Max Points} { - Submission Ti set skipCreationCol [concat $commonInfoCol $infoColumsMarkers] ###################################################################### -if { $argc < 2 } { - puts {Usage:} - puts " $argv0 gradebook.sqlitedb blackboard.sqlitedb" - puts {} - puts { expect both files to be sqilte tables:} - puts { blackboard should have a single table 'export_table':} - puts {Example:} - puts [concat " $argv0" { 2020_Fall_Phys251 blackboard.db}] - exit -} - set classDB [lindex $argv 0] set blackboardDB [lindex $argv 1] |