@@ -37,7 +37,7 @@ import (
3737// set global variables
3838
3939// set the version of the app here
40- // TODO - maybe check for newer version and update if needed
40+ // TODO - maybe check for newer version and update if needed?
4141var appversion string = "0.6"
4242
4343// below used by flag for command line args
@@ -49,6 +49,8 @@ var helpMe bool
4949
5050// init() function - always runs before main() - used here to set-up required flags variables
5151// from the command line parameters provided by the user when they run the app
52+ // TODO: add -s for silent (no output unless error) | add -v to just display current version (how to add build date too?)
53+ //
5254func init () {
5355 // IntVar; StringVar; BoolVar all required: variable, cmd line flag, initial value, description used by flag.Usage() on error / help
5456 flag .StringVar (& tableName , "t" , "" , "\t USE: '-t tablename' where tablename is the name of the SQLite table to hold your CSV file data [MANDATORY]" )
@@ -59,17 +61,19 @@ func init() {
5961}
6062
6163//
62- // FUNCTION: create a filename string for the SQL data to be written too - return it
64+ // FUNCTION: create a string to be used as the filename for the output SQL data file - return it
6365//
6466func SQLFileName () (filename string ) {
6567 // include the name of the csv file from command line (ie csvFileName)
6668 // remove any path etc
6769 var justFileName = filepath .Base (csvFileName )
70+ // get the files extension too
6871 var extension = filepath .Ext (csvFileName )
69- // remove the file extn
72+ // remove the file extension from the filename
7073 justFileName = justFileName [0 : len (justFileName )- len (extension )]
7174 // get a date and time stamp - use GoLang reference date of: Mon Jan 2 15:04:05 MST 2006
7275 // TODO: figure out how to make this work - so filename has timestamp too ??
76+ // will help stop the previously generated file being overwitten each time it is run
7377 //fileDate, err := time.Parse("2006-01-02", time.Now().String())
7478 //if err != nil {
7579 // panic(err)
@@ -81,9 +85,9 @@ func SQLFileName() (filename string) {
8185}
8286
8387//
84- // FUNCTION: display a banner and help information on the screen
85- // information is displayed when the program is run without including
86- // any command line parameters - so assumes you want help to run it
88+ // FUNCTION: display a banner and help information on the screen.
89+ // Information is displayed when the program is run with -h
90+ // command line parameter - so assumes you want addtional help
8791//
8892func printBanner () {
8993 // add the help and about text to the variable 'about' in the form shown below
@@ -231,7 +235,7 @@ func main() {
231235 //-------------------------------------------------------------------------
232236 // get a new filename to write the SQl converted data into - call our
233237 // function SQLFileName() to obtain a suitable string for the new filename
234- // TODO : ad option to output to stdout instead of a file only
238+ // TODO : add option to output to stdout instead of a file only
235239 sqlOutFile := SQLFileName ()
236240 if debugSwitch {
237241 fmt .Println ("Opening the SQL output file:" , sqlOutFile )
@@ -289,7 +293,7 @@ func main() {
289293 // if we are processing the first line - use the record field contents
290294 // as the SQL table column names - add to the temp string 'strbuffer'
291295 // use the tablename provided by the user
292- // TODO - add option to skip this line if user is adding data to an existing table?
296+ // TODO : - add option to skip this line if user is adding data to an existing table?
293297 if lineCount == 0 {
294298 strbuffer .WriteString ("PRAGMA foreign_keys=OFF;\n BEGIN TRANSACTION;\n CREATE TABLE " + tableName + " (" )
295299 }
@@ -386,7 +390,7 @@ func main() {
386390// Function is used to clean up the CSV file header fields as they will be used for column table names
387391// in our SQLIte database. Therefore we don't want any odd characters for our table column names
388392//
389- // TODO: consider using: strings.NewReplacer function instead?
393+ // TODO : consider using: strings.NewReplacer function instead?
390394//
391395func cleanHeader (headField string ) string {
392396 // ok - remove any spaces and replace with _
0 commit comments