Implement the core logic for comparing two archives (diff) and performing incremental updates (sync). - Introduces a new `borg diff` command to show differences between two collection archives. - Adds new `pkg/diff` and `pkg/sync` packages with corresponding business logic and unit tests. - The `diff` command supports reading compressed archives and prints a formatted summary of added, removed, and modified files. - The `sync` package includes `append`, `mirror`, and `update` strategies. Next steps involve integrating the sync logic into the `collect` commands. Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
31 lines
916 B
Go
31 lines
916 B
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func NewRootCmd() *cobra.Command {
|
|
rootCmd := &cobra.Command{
|
|
Use: "borg",
|
|
Short: "A tool for collecting and managing data.",
|
|
Long: `Borg Data Collector is a command-line tool for cloning Git repositories,
|
|
packaging their contents into a single file, and managing the data within.`,
|
|
}
|
|
|
|
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Enable verbose logging")
|
|
rootCmd.AddCommand(NewDiffCmd())
|
|
return rootCmd
|
|
}
|
|
|
|
// RootCmd represents the base command when called without any subcommands
|
|
var RootCmd = NewRootCmd()
|
|
|
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
|
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
|
func Execute(log *slog.Logger) error {
|
|
RootCmd.SetContext(context.WithValue(context.Background(), "logger", log))
|
|
return RootCmd.Execute()
|
|
}
|