Files
HackBrowserData/cmd/hack-browser-data/archive.go
T
Roger 3e9150249c refactor: rename core types and spell out every name (#677)
Def, Request, DirID, and Source said too little, and short variables and doc comments that skip their name hid intent.
varnamelen and staticcheck ST1020-22 now keep both from coming back.
2026-11-02 11:06:05 +08:00

46 lines
1.3 KiB
Go

package main
import (
"github.com/spf13/cobra"
"github.com/moond4rk/hackbrowserdata/internal/app"
"github.com/moond4rk/hackbrowserdata/internal/log"
)
func archiveCmd() *cobra.Command {
var (
flags app.Flags
outputPath string
)
command := &cobra.Command{
Use: "archive",
Short: "Pack decryption-relevant profile files into a zip for cross-host restore",
Example: ` hack-browser-data archive
hack-browser-data archive -b chrome -c cookie -o chrome-cookies.zip`,
RunE: func(command *cobra.Command, args []string) error {
options, err := app.ValidateArchive(flags)
if err != nil {
return err
}
discovery := app.Discover(options)
if len(discovery.Dirs) == 0 {
log.Warnf("no browsers found")
return nil
}
fileCount, err := app.Archive(command.Context(), discovery, options, outputPath)
if err != nil {
return err
}
log.Infof("Archived %d entries to %s", fileCount, outputPath)
return nil
},
}
command.Flags().StringVarP(&flags.Browser, "browser", "b", "all", "target browser: all|"+browserNames())
command.Flags().StringVarP(&flags.Categories, "category", "c", "all", "data categories (comma-separated): all|"+categoryNames())
command.Flags().StringVarP(&outputPath, "output", "o", "browser-data.zip", "output archive of decryption-relevant browser files")
return command
}