Documentation
¶
Overview ¶
Package backupcmd provides the "admin backup" command, which creates a JSONL backup of the entire issue database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBackupFilename ¶
DefaultBackupFilename returns a timestamped backup filename, optionally including the database prefix. The prefix is sanitized to contain only ASCII letters, preventing path traversal from a corrupt or malicious database prefix.
Types ¶
type RunInput ¶
type RunInput struct {
// DiscoverFunc locates the database file, returning its absolute path.
// In production this is Factory.DatabasePath (workspace-aware); tests
// provide a stub. Only called when Output is empty — the discovered
// .np/ directory determines the default backup location.
DiscoverFunc func() (string, error)
// BackupFunc performs the actual backup, writing issue data to the
// provided writer and returning the number of issues written. In
// production this wraps svc.Backup; tests provide a stub. The
// writer is a gzip.Writer that the caller manages — BackupFunc
// should not close it.
BackupFunc func(w io.WriteCloser) (int, error)
// Output is the user-specified destination path. When empty, the
// backup file is written to the discovered .np/ directory with a
// timestamp-based filename.
Output string
// JSON enables machine-readable JSON output.
JSON bool
// WriteTo receives the command's human-readable or JSON output.
WriteTo io.Writer
// Prefix is the database's issue ID prefix (e.g., "NP"). When
// non-empty and the default filename is used (Output is empty or
// Output is a directory), the prefix is included in the filename:
// backup-<prefix>.<timestamp>.jsonl.gz.
Prefix string
// SuccessIcon returns a colored or plain success indicator for
// human-readable output. When nil, a default "[ok]" is used.
SuccessIcon func() string
}
RunInput holds the parameters for the backup command's core logic, decoupled from CLI flag parsing so it can be tested directly.
Click to show internal directories.
Click to hide internal directories.