Skip to content
Merged
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
29 changes: 29 additions & 0 deletions backup/cmd/check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cmd

import (
"fmt"

"backup-rsync/backup/internal"

"github.com/spf13/afero"
"github.com/spf13/cobra"
)

var AppFs = afero.NewOsFs()

var checkCmd = &cobra.Command{
Use: "check-coverage",
Short: "Check path coverage",
Run: func(cmd *cobra.Command, args []string) {
cfg := loadResolvedConfig(configPath)
uncoveredPaths := internal.ListUncoveredPaths(AppFs, cfg)
fmt.Println("Uncovered paths:")
for _, path := range uncoveredPaths {
fmt.Println(path)
}
},
}

func init() {
RootCmd.AddCommand(checkCmd)
}
2 changes: 1 addition & 1 deletion backup/internal/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func isCovered(path string, jobs []Job) bool {
return false
}

func listUncoveredPaths(fs afero.Fs, cfg Config) []string {
func ListUncoveredPaths(fs afero.Fs, cfg Config) []string {
var result []string
seen := make(map[string]bool)

Expand Down
2 changes: 1 addition & 1 deletion backup/internal/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func runListUncoveredPathsTest(t *testing.T, fakeFS map[string][]string, cfg Con
}

// Call the function
uncoveredPaths := listUncoveredPaths(fs, cfg)
uncoveredPaths := ListUncoveredPaths(fs, cfg)

// Assertions
sort.Strings(uncoveredPaths)
Expand Down