Files
HackBrowserData/cmd/hack-browser-data/list.go
T
Roger 4363516ca4 refactor(browser): one extractor input, restore by kind (#694)
Safari's keychain now reaches extractors through the same Input as Chromium's keys, so every base's tables
are static and share one signature; restore reads a fork this build lacks under its own name.
2026-11-10 17:00:44 +08:00

45 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 newListCommand() *cobra.Command {
var detail bool
command := &cobra.Command{
Use: "list",
Short: "List detected browsers and profiles",
Example: ` hack-browser-data list
hack-browser-data list --detail`,
RunE: func(command *cobra.Command, args []string) error {
options, err := app.ValidateList()
if err != nil {
return err
}
discovery := app.Discover(command.Context(), options.Target)
for _, failure := range discovery.DirFailures {
log.Warnf("%s: %v", failure.UserDataDirID, failure.Err)
}
if len(discovery.Dirs) == 0 {
command.Println("No browsers found.")
return nil
}
if !detail {
return printProfiles(command.OutOrStdout(), discovery)
}
summary, err := app.CountRecords(command.Context(), discovery, options.Keychain)
if err != nil {
return err
}
return printRecordCounts(command.OutOrStdout(), discovery, summary)
},
}
command.Flags().BoolVar(&detail, "detail", false, "show per-category entry counts")
return command
}