Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ func TestIntegration(t *testing.T) {
// Actually, `FindBackupRoot` supports "proj/timestamp".
// But `snapshots` command calls `BackupRoots()` which lists `searchDir`.
// If we want to list snapshots for a project headless:
// We can't currently without config.
// We might need to add back `--name` flag later?
// OR: `backup-cli` should maybe auto-discover projects?
// Let's stick to what we have:
// We use the --name flag.
out = run(storeDir, "--store", storeDir, "snapshots", "--name", projectName)
if !strings.Contains(out, snapshot1) {
t.Errorf("Snapshots with --name flag failed to list snapshot %s. Output: %s", snapshot1, out)
}

// Try `restore` with explicit project path "integration-test-proj/<snap2>".

targetRestore := filepath.Join(tempDir, "restore_from_store")
Expand Down
13 changes: 11 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ func main() {
Name: "snapshots",
Aliases: []string{"snapshot", "list"},
Usage: "List backup snapshots",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "Project name (for headless mode)",
},
},
Action: func(c *cli.Context) error {
return runSnapshots(b)
return runSnapshots(b, c.String("name"))
},
},
{
Expand Down Expand Up @@ -316,7 +322,10 @@ func main() {
}
}

func runSnapshots(b *internal.Backup) error {
func runSnapshots(b *internal.Backup, projectName string) error {
if projectName != "" {
b.ProjectName = projectName
}
roots, err := b.BackupRoots()
if err != nil {
return fmt.Errorf("failed to list backups: %w", err)
Expand Down
Loading