Skip to content

Commit

Permalink
Update list command
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m committed Oct 28, 2024
1 parent c07c401 commit 4ab4379
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
34 changes: 34 additions & 0 deletions migrations/list_tables/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package list

import (
"fmt"
"slices"

"migrate/kdvh"
)

type Config struct {
System string `short:"d" long:"db" default:"all" choice:"kdvh" choice:"kvlaobs" choice:"all" description:"Name of the database you want to dump data from"`
}

func (config *Config) Execute(_ []string) error {
if config.System == "kdvh" || config.System == "all" {
fmt.Println("Available tables in KDVH:")

var tables []string
for table := range kdvh.Init().Tables {
tables = append(tables, table)
}

slices.Sort(tables)
for _, table := range tables {
fmt.Println(" -", table)
}
}

if config.System == "kvalobs" || config.System == "all" {
// TODO
}

return nil
}
11 changes: 2 additions & 9 deletions migrations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@ import (

"migrate/dump"
"migrate/import"
"migrate/list_tables"
)

type CmdArgs struct {
List ListConfig `command:"list" description:"List available tables"`
List list.Config `command:"list" description:"List available tables"`
Dump dump.Config `command:"dump" description:"Dump tables from KDVH to CSV"`
Import port.Config `command:"import" description:"Import dumped CSV files"`
}

type ListConfig struct{}

func (config *ListConfig) Execute(_ []string) error {
fmt.Println("Available tables:")
// TODO: refactor
return nil
}

func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)

Expand Down

0 comments on commit 4ab4379

Please sign in to comment.