lost

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package lost implements the `wherehouse lost` command that marks items as lost/missing.

This command moves items to the system "Missing" location while preserving their home location information. When an item is marked as missing, its original home location is preserved so it can be returned when found.

The command supports multiple selector types for item identification:

  • ID: Exact ID match (verified against database)
  • LOCATION:ITEM: Scoped selector using canonical names
  • Canonical name: Must match exactly one item

Event-Sourcing Design

This command creates an "item.missing" event, which triggers the event handler to move the item to the Missing system location. The home location (temp_origin_location_id) is preserved automatically by the event handler.

Business Rules

Validation before event creation:

  • Item must exist in database
  • Item must NOT already be in Missing location (prevents duplicate events)
  • Borrowed items CAN be marked as missing (borrowed → missing is valid)
  • previous_location_id must match current projection state

Examples

wherehouse lost "10mm socket"
wherehouse lost garage:socket --note "checked toolbox"
wherehouse lost aB3xK9mPqR

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLostCmd deprecated

func GetLostCmd() *cobra.Command

GetLostCmd returns the lost command using the default database.

Deprecated: Use NewDefaultLostCmd instead.

func NewDefaultLostCmd

func NewDefaultLostCmd() *cobra.Command

NewDefaultLostCmd returns a lost command that opens the database from context configuration at runtime. This is the production entry point registered with the root command.

func NewLostCmd

func NewLostCmd(db lostDB) *cobra.Command

NewLostCmd returns a lost command that uses the provided db for all database operations. The caller retains no reference to db after this call; the returned command's RunE closes it via defer before returning.

Types

type Result

type Result struct {
	ItemID           string `json:"item_id"`
	DisplayName      string `json:"display_name"`
	PreviousLocation string `json:"previous_location"`
	EventID          int64  `json:"event_id"`
}

Result represents the result of marking an item as lost.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL