Last active
August 6, 2022 03:32
-
-
Save dele454/f58061d5a7983fc83ff61b13cd04ec85 to your computer and use it in GitHub Desktop.
Part 1 - CSV Transformation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"os" | |
"github.com/dele454/medium/csv-transform-to-html/cmd" | |
"github.com/dele454/medium/csv-transform-to-html/internal/errs" | |
) | |
func main() { | |
var file string | |
// accept arg from stdin | |
flag.StringVar(&file, "f", "", "Full path to source file for processing.") | |
flag.Parse() | |
// display usage if no arg is passed | |
if len(os.Args[1:]) == 0 { | |
flag.PrintDefaults() | |
return | |
} | |
// get file's info | |
f, err := os.Stat(file) | |
if err != nil { | |
panic(err) | |
} | |
// check its a file | |
if f.IsDir() { | |
panic(errs.ErrorArgsDirSpecified) | |
} | |
// kickoff the process | |
cmd.Process(file) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment