| | @@ -17,11 +17,12 @@ |
| 17 | 17 | |
| 18 | 18 | # # ## ### ##### ######## ############# ##################### |
| 19 | 19 | ## Requirements |
| 20 | 20 | |
| 21 | 21 | package require Tcl 8.4 ; # Required runtime. |
| 22 | | -package require snit ; # OO system |
| 22 | +package require snit ; # OO system. |
| 23 | +package require vc::tools::trouble ; # Error reporting. |
| 23 | 24 | |
| 24 | 25 | # # ## ### ##### ######## ############# ##################### |
| 25 | 26 | ## |
| 26 | 27 | |
| 27 | 28 | snit::type ::vc::fossil::import::cvs::option { |
| | @@ -75,12 +76,59 @@ |
| 75 | 76 | Validate |
| 76 | 77 | return |
| 77 | 78 | } |
| 78 | 79 | |
| 79 | 80 | # # ## ### ##### ######## ############# |
| 80 | | - ## Internal methods and state |
| 81 | + ## Internal methods, printing information. |
| 82 | + |
| 83 | + proc PrintHelp {} { |
| 84 | + global argv0 |
| 85 | + trouble info "Usage: $argv0 $usage" |
| 86 | + trouble info "" |
| 87 | + trouble info " Information options" |
| 88 | + trouble info "" |
| 89 | + trouble info " -h, --help Print this message and exit with success" |
| 90 | + trouble info " --help-passes Print list of passes and exit with success" |
| 91 | + trouble info " --version Print version number of $argv0" |
| 92 | + trouble info "" |
| 93 | + # --project, --cache |
| 94 | + # ... |
| 95 | + exit 0 |
| 96 | + } |
| 97 | + |
| 98 | + proc PrintHelpPasses {} { |
| 99 | + trouble info "" |
| 100 | + trouble info "Conversion passes:" |
| 101 | + trouble info "" |
| 102 | + set n 0 |
| 103 | + foreach {p desc} { |
| 104 | + CollectAr {Collect archives} |
| 105 | + CollectRev {Collect revisions} |
| 106 | + } { trouble info " [format %2d $n]: $p $desc" ; incr n } |
| 107 | + trouble info "" |
| 108 | + exit 0 |
| 109 | + } |
| 110 | + |
| 111 | + proc PrintVersion {} { |
| 112 | + global argv0 |
| 113 | + set v [package require vc::fossil::import::cvs] |
| 114 | + trouble info "$argv0 v$v" |
| 115 | + exit 0 |
| 116 | + } |
| 117 | + |
| 118 | + proc Usage {{text {}}} { |
| 119 | + global argv0 |
| 120 | + if {$text ne ""} {set text \n$text} |
| 121 | + trouble fatal "Usage: $argv0 $usage$text" |
| 122 | + # Not reached |
| 123 | + return |
| 124 | + } |
| 125 | + |
| 126 | + # # ## ### ##### ######## ############# |
| 127 | + ## Internal methods, command line processing |
| 81 | 128 | |
| 129 | + typevariable usage "?option ?value?...? cvs-repository-path" |
| 82 | 130 | typevariable nocvs " The cvs-repository-path is missing." |
| 83 | 131 | typevariable badoption " Bad option " |
| 84 | 132 | typevariable gethelp " Use --help to get help." |
| 85 | 133 | |
| 86 | 134 | proc IsOption {av _ ov} { |
| | @@ -97,32 +145,31 @@ |
| 97 | 145 | set v [lindex $arguments 0] |
| 98 | 146 | set arguments [lrange $arguments 1 end] |
| 99 | 147 | return $v |
| 100 | 148 | } |
| 101 | 149 | |
| 150 | + # # ## ### ##### ######## ############# |
| 151 | + ## Internal methods, state validation |
| 152 | + |
| 102 | 153 | proc Validate {} { |
| 103 | 154 | return |
| 104 | 155 | } |
| 105 | 156 | |
| 106 | | - proc Usage {{text {}}} { |
| 107 | | - global argv0 |
| 108 | | - if {$text ne ""} {set text \n$text} |
| 109 | | - #trouble fatal "Usage: $argv0 ?option ?value?...? cvs-repository-path$text" |
| 110 | | - puts "Usage: $argv0 ?option ?value?...? cvs-repository-path$text" |
| 111 | | - exit 1 |
| 112 | | - } |
| 113 | | - |
| 114 | 157 | # # ## ### ##### ######## ############# |
| 115 | 158 | ## Configuration |
| 116 | 159 | |
| 117 | 160 | pragma -hasinstances no ; # singleton |
| 118 | 161 | pragma -hastypeinfo no ; # no introspection |
| 119 | 162 | pragma -hastypedestroy no ; # immortal |
| 120 | 163 | |
| 121 | 164 | # # ## ### ##### ######## ############# |
| 122 | 165 | } |
| 166 | + |
| 167 | +namespace eval ::vc::fossil::import::cvs::option { |
| 168 | + namespace import ::vc::tools::trouble |
| 169 | +} |
| 123 | 170 | |
| 124 | 171 | # # ## ### ##### ######## ############# ##################### |
| 125 | 172 | ## Ready |
| 126 | 173 | |
| 127 | 174 | package provide vc::fossil::import::cvs::option 1.0 |
| 128 | 175 | return |
| 129 | 176 | |
| 130 | 177 | ADDED tools/cvs2fossil/lib/log.tcl |