Skip to content

Commit 26e9071

Browse files
committed
🔧 Add support for --table flag
1 parent 18907e1 commit 26e9071

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/dump/dump.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
ifExists bool
3636
clean bool
3737
noOwner bool
38+
tables []string
3839
excludeTable []string
3940
excludeTableData []string
4041
)
@@ -50,6 +51,7 @@ func init() {
5051
Command.Flags().BoolVar(&ifExists, "if-exists", true, "use IF EXISTS when dropping objects")
5152
Command.Flags().BoolVarP(&clean, "clean", "c", true, "clean (drop) database objects before recreating")
5253
Command.Flags().BoolVarP(&noOwner, "no-owner", "O", true, "skip restoration of object ownership in plain-text format")
54+
Command.Flags().StringSliceVarP(&tables, "table", "t", []string{}, "dump the specified table(s) only")
5355
Command.Flags().StringSliceVarP(&excludeTable, "exclude-table", "T", []string{}, "do NOT dump the specified table(s)")
5456
Command.Flags().StringSliceVar(&excludeTableData, "exclude-table-data", []string{}, "do NOT dump data for the specified table(s)")
5557
}
@@ -178,11 +180,14 @@ func buildCommand() []string {
178180
if ifExists {
179181
cmd = append(cmd, "--if-exists")
180182
}
183+
for _, table := range tables {
184+
cmd = append(cmd, "--table="+table)
185+
}
181186
for _, table := range excludeTable {
182-
cmd = append(cmd, "--exclude-table=" + table)
187+
cmd = append(cmd, "--exclude-table="+table)
183188
}
184189
for _, table := range excludeTableData {
185-
cmd = append(cmd, "--exclude-table-data=" + table)
190+
cmd = append(cmd, "--exclude-table-data="+table)
186191
}
187192
if outputFormat == sqlformat.Custom {
188193
cmd = append(cmd, "--format=c")

0 commit comments

Comments
 (0)