31 lines
631 B
Go
31 lines
631 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
var Version = "develop"
|
|
|
|
func main() {
|
|
fs := flag.NewFlagSet("imp", flag.ExitOnError)
|
|
writeFlag := fs.Bool("write", false, "Write the re-ordered imports instead of just printing them")
|
|
fs.BoolVar(writeFlag, "w", *writeFlag, "--write")
|
|
ignoreFlag := fs.String("ignore", ".impignore", "Path to .impignore file")
|
|
fs.StringVar(ignoreFlag, "i", *ignoreFlag, "--ignore")
|
|
|
|
if err := fs.Parse(os.Args[1:]); err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
|
|
root := "."
|
|
if fs.NArg() > 0 {
|
|
root = fs.Arg(0)
|
|
}
|
|
|
|
if err := runImp(root, *ignoreFlag, *writeFlag); err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
}
|