mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
* refactor(app): per-command flags and per-stage inputs One Options bag fed every stage and cmd patched restore's keys into it after validation; each stage now takes what it reads, dir-level failures are their own type, and cmd prints what a run exported. * refactor(app): group the plan by dir and profile Execute now walks the plan's own shape instead of filtering a flat list and looking profiles up by name. * refactor(app): file code by command and stage Pure moves: each command's flags and validation sit beside its stage, and execute.go keeps only the runner. * refactor: read the keychain password in cmd Prompting and reading stdin are terminal work, so app now receives the password func; cobra already rejects both flags. * refactor(app): plan each user data dir right before it runs A run-wide Plan had to drop its extractors and rebuild them with the keychain; per-dir planning keeps one extractor.
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/internal/category"
|
|
"github.com/moond4rk/hackbrowserdata/internal/record"
|
|
)
|
|
|
|
// ListOptions is what list reads: every browser and category, with the keychain left locked, so counting never prompts.
|
|
func ListOptions() (Options, error) {
|
|
home, err := homeDir()
|
|
if err != nil {
|
|
return Options{}, err
|
|
}
|
|
return Options{
|
|
Target: Target{BrowserName: allBrowsers, HomeDir: home},
|
|
Categories: category.All(),
|
|
Keychain: KeychainConfig{HomeDir: home},
|
|
}, nil
|
|
}
|
|
|
|
// CountRecords runs with no key and the keychain locked, counting records instead of exporting them.
|
|
func CountRecords(
|
|
ctx context.Context, discovery Discovery, categories []category.Category, keychainConfig KeychainConfig,
|
|
) (Summary, error) {
|
|
keychain := newLoginKeychain(keychainConfig)
|
|
counter := runner{writer: discard{}, extractors: extractorsWith(keychain), retrieveKeys: keysFromFile(nil)}
|
|
return counter.run(ctx, discovery, categories)
|
|
}
|
|
|
|
type discard struct{}
|
|
|
|
func (discard) Write(category.Category, []record.Record) error { return nil }
|