Compare commits
2 Commits
0bfcd7a8a9
...
77260743a0
Author | SHA1 | Date | |
---|---|---|---|
|
77260743a0 | ||
|
36d0eacf8f |
7
flag.go
7
flag.go
@ -20,12 +20,14 @@ func (i *arrayFlags) Set(value string) error {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
flagVersion bool
|
flagVersion bool
|
||||||
|
flagList bool
|
||||||
flagIncludeAll bool
|
flagIncludeAll bool
|
||||||
flagExcludeAll bool
|
flagExcludeAll bool
|
||||||
flagExcept arrayFlags
|
flagExcept arrayFlags
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
flag.BoolVar(&flagList, "list", false, "Only list database names.")
|
||||||
flag.BoolVar(&flagVersion, "version", false, "Prints version and exits.")
|
flag.BoolVar(&flagVersion, "version", false, "Prints version and exits.")
|
||||||
flag.BoolVar(&flagIncludeAll, "include-all", false, "Split out all databases, with provided exceptions.")
|
flag.BoolVar(&flagIncludeAll, "include-all", false, "Split out all databases, with provided exceptions.")
|
||||||
flag.BoolVar(&flagExcludeAll, "exclude-all", false, "Split out no databases, with provided exceptions.")
|
flag.BoolVar(&flagExcludeAll, "exclude-all", false, "Split out no databases, with provided exceptions.")
|
||||||
@ -37,6 +39,11 @@ func init() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if flagList && (flagIncludeAll || flagExcludeAll || len(flagExcept) > 0) {
|
||||||
|
fmt.Println("-list is not usable with any other flag.")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if flagIncludeAll && flagExcludeAll {
|
if flagIncludeAll && flagExcludeAll {
|
||||||
fmt.Println("-include-all and -exclude-all are mutually exclusive")
|
fmt.Println("-include-all and -exclude-all are mutually exclusive")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
6
main.go
6
main.go
@ -9,7 +9,7 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "v2"
|
const VERSION = "v3"
|
||||||
const MAXLINE = 1048576
|
const MAXLINE = 1048576
|
||||||
|
|
||||||
type Db struct {
|
type Db struct {
|
||||||
@ -75,11 +75,11 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if db.IsOpen() {
|
if !flagList && db.IsOpen() {
|
||||||
db.Write(line)
|
db.Write(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
if dbDone.MatchString(line) {
|
if !flagList && dbDone.MatchString(line) {
|
||||||
db.Completed = true
|
db.Completed = true
|
||||||
db.Close()
|
db.Close()
|
||||||
prevDb = db
|
prevDb = db
|
||||||
|
Loading…
Reference in New Issue
Block a user