mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-06 21:37:47 +02:00
feat: add output package with Formatter interface (#537)
* docs: add RFC-004 for CLI (cobra) and output design * feat: add output package with Formatter interface and BrowserData.Each * fix: golangci config array syntax + add output package tests * refactor: encapsulated Output as Writer, collect-then-write pattern * refactor: unified row type with reflection-based CSV/JSON output * fix: ProfileName empty guard, writeFile close error check, sync RFC-004
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package output
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// formatter serializes rows to a writer. Unexported — only used by Writer.
|
||||
type formatter interface {
|
||||
format(w io.Writer, rows []row) error
|
||||
ext() string
|
||||
}
|
||||
|
||||
func newFormatter(name string) (formatter, error) {
|
||||
switch name {
|
||||
case "csv":
|
||||
return &csvFormatter{}, nil
|
||||
case "json":
|
||||
return &jsonFormatter{}, nil
|
||||
case "cookie-editor":
|
||||
return &cookieEditorFormatter{}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported format: %s", name)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user