Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_option.tcl part of check-in [2a98ac44bd] - Third attempt at getting a cvs importer which can handle branches. Using cvs2svn code and design notes as a guide. by aku on 2007-10-02 03:05:43. [view]

To:

File tools/cvs2fossil/lib/c2f_option.tcl part of check-in [d57b7b4a05] - Re-added the user feedback and error reporting utilities, with modifications, and completed the handling of the informational options. by aku on 2007-10-02 05:33:09. [view]

@@ -18,9 +18,10 @@
 # # ## ### ##### ######## ############# #####################
 ## Requirements
 
 package require Tcl 8.4                         ; # Required runtime.
-package require snit                            ; # OO system
+package require snit                            ; # OO system.
+package require vc::tools::trouble              ; # Error reporting.
 
 # # ## ### ##### ######## ############# #####################
 ##
 
@@ -76,10 +77,57 @@
 	return
     }
 
     # # ## ### ##### ######## #############
-    ## Internal methods and state
+    ## Internal methods, printing information.
+
+    proc PrintHelp {} {
+	global argv0
+	trouble info "Usage: $argv0 $usage"
+	trouble info ""
+	trouble info "  Information options"
+	trouble info ""
+	trouble info "    -h, --help    Print this message and exit with success"
+	trouble info "    --help-passes Print list of passes and exit with success"
+	trouble info "    --version     Print version number of $argv0"
+	trouble info ""
+	# --project, --cache
+	# ...
+	exit 0
+    }
+
+    proc PrintHelpPasses {} {
+	trouble info ""
+	trouble info "Conversion passes:"
+	trouble info ""
+	set n 0
+	foreach {p desc} {
+	    CollectAr  {Collect archives}
+	    CollectRev {Collect revisions}
+	} { trouble info "  [format %2d $n]: $p $desc" ; incr n }
+	trouble info ""
+	exit 0
+    }
+
+    proc PrintVersion {} {
+	global argv0
+	set v [package require vc::fossil::import::cvs]
+	trouble info "$argv0 v$v"
+	exit 0
+    }
+
+    proc Usage {{text {}}} {
+	global argv0
+	if {$text ne ""} {set text \n$text}
+	trouble fatal "Usage: $argv0 $usage$text"
+	# Not reached
+	return
+    }
+
+    # # ## ### ##### ######## #############
+    ## Internal methods, command line processing
 
+    typevariable usage     "?option ?value?...? cvs-repository-path"
     typevariable nocvs     "       The cvs-repository-path is missing."
     typevariable badoption "       Bad option "
     typevariable gethelp   "       Use --help to get help."
 
@@ -98,18 +146,13 @@
 	set arguments [lrange $arguments 1 end]
 	return $v
     }
 
+    # # ## ### ##### ######## #############
+    ## Internal methods, state validation
+
     proc Validate {} {
 	return
-    }
-
-    proc Usage {{text {}}} {
-	global argv0
-	if {$text ne ""} {set text \n$text}
-	#trouble fatal "Usage: $argv0 ?option ?value?...? cvs-repository-path$text"
-	puts "Usage: $argv0 ?option ?value?...? cvs-repository-path$text"
-	exit 1
     }
 
     # # ## ### ##### ######## #############
     ## Configuration
@@ -118,11 +161,15 @@
     pragma -hastypeinfo    no ; # no introspection
     pragma -hastypedestroy no ; # immortal
 
     # # ## ### ##### ######## #############
+}
+
+namespace eval ::vc::fossil::import::cvs::option {
+    namespace import ::vc::tools::trouble
 }
 
 # # ## ### ##### ######## ############# #####################
 ## Ready
 
 package provide vc::fossil::import::cvs::option 1.0
 return