2025-10-31 05:02:29 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
import (
|
2025-11-02 00:59:46 +00:00
|
|
|
"context"
|
|
|
|
|
"log/slog"
|
|
|
|
|
|
2025-10-31 05:02:29 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
2025-11-02 17:57:09 +00:00
|
|
|
func NewRootCmd() *cobra.Command {
|
|
|
|
|
rootCmd := &cobra.Command{
|
2025-11-03 02:36:38 +00:00
|
|
|
Use: "borg",
|
2025-11-02 17:57:09 +00:00
|
|
|
Short: "A tool for collecting and managing data.",
|
|
|
|
|
Long: `Borg Data Collector is a command-line tool for cloning Git repositories,
|
2025-10-31 05:02:29 +00:00
|
|
|
packaging their contents into a single file, and managing the data within.`,
|
2025-11-02 17:57:09 +00:00
|
|
|
}
|
2025-11-03 02:36:38 +00:00
|
|
|
|
2025-11-02 17:57:09 +00:00
|
|
|
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Enable verbose logging")
|
|
|
|
|
return rootCmd
|
2025-10-31 05:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-02 17:57:09 +00:00
|
|
|
// RootCmd represents the base command when called without any subcommands
|
|
|
|
|
var RootCmd = NewRootCmd()
|
|
|
|
|
|
2025-10-31 05:02:29 +00:00
|
|
|
// 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.
|
2025-11-02 00:59:46 +00:00
|
|
|
func Execute(log *slog.Logger) error {
|
|
|
|
|
RootCmd.SetContext(context.WithValue(context.Background(), "logger", log))
|
|
|
|
|
return RootCmd.Execute()
|
2025-10-31 05:02:29 +00:00
|
|
|
}
|