mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
* refactor(app): export one function per command Step 2 of #710. A command's logic was split between cmd and stage-shaped app calls; cmd now parses flags, calls one function and prints what it returns. An error means the command never ran, and a run that ended early says so in Summary.Err. * fix(app): check dumpkeys and archive -o up front A missing output directory was reported only after the keys were retrieved or the files copied. * docs(rfcs): move restore's input out of the command layer Restore now discovers its directories in an archive itself, so the command layer no longer holds the data it reads.
40 lines
1019 B
Go
40 lines
1019 B
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 {
|
|
discovery, summary, err := app.List(command.Context(), detail)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
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)
|
|
}
|
|
return printRecordCounts(command.OutOrStdout(), discovery, summary)
|
|
},
|
|
}
|
|
|
|
command.Flags().BoolVar(&detail, "detail", false, "show per-category entry counts")
|
|
return command
|
|
}
|