Files
HackBrowserData/cmd/hack-browser-data/archive.go
T
Roger bbd353f314 refactor: run every command on the pipeline (#665)
dump, dumpkeys, archive, restore, and list now run on the app stages, so cmd's old path goes away.
archive writes manifest.json and restore reads it, falling back to today's layout for older archives.
Windows and macOS smoke matched today's output apart from the planned changes.
2026-10-29 14:15:59 +08:00

46 lines
1.2 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 (
f app.Flags
outputPath string
)
cmd := &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(cmd *cobra.Command, args []string) error {
req, err := app.ValidateArchive(f)
if err != nil {
return err
}
d := app.Discover(req)
if len(d.Dirs) == 0 {
log.Warnf("no browsers found")
return nil
}
n, err := app.Archive(cmd.Context(), d, req, outputPath)
if err != nil {
return err
}
log.Infof("Archived %d entries to %s", n, outputPath)
return nil
},
}
cmd.Flags().StringVarP(&f.Browser, "browser", "b", "all", "target browser: all|"+browserNames())
cmd.Flags().StringVarP(&f.Categories, "category", "c", "all", "data categories (comma-separated): all|"+categoryNames())
cmd.Flags().StringVarP(&outputPath, "output", "o", "browser-data.zip", "output archive of decryption-relevant browser files")
return cmd
}