Skip to content

Add CRUD commands for notes #14

@pepicrft

Description

@pepicrft

Overview

Add CLI commands to create, read, update, and delete notes without manually creating timestamp-based files.

Motivation

Notes use Unix timestamps as filenames, which is cumbersome to create manually. CLI commands would make microblogging with Gesttalt seamless and eliminate the need to calculate timestamps.

Proposed Commands

Create Note

```bash
gesttalt note create [OPTIONS]
```

Options:

  • --content <text> - Note content (optional, opens $EDITOR if not provided)
  • --slug <slug> - Custom slug override (optional)
  • --timestamp <unix-timestamp> - Custom timestamp (default: now)
  • --dir <dir> - Project directory (default: current)

Behavior:

  • Generates Unix timestamp if not provided
  • Creates file: content/notes/<timestamp>.md
  • Adds frontmatter only if slug is provided
  • Opens in $EDITOR if no content provided

Examples:
```bash

Quick note

gesttalt note create --content "Just shipped the new feature!"

Note with custom slug

gesttalt note create --slug "shipped-feature" --content "Just shipped the new feature!"

Interactive (opens editor)

gesttalt note create
```

List Notes

```bash
gesttalt note list [OPTIONS]
```

Options:

  • --dir <dir> - Project directory (default: current)
  • --format <format> - Output format: table, json, csv (default: table)
  • --limit <n> - Number of notes to show (default: 10)

Output:

  • Timestamp/ID, date, content preview (first 50 chars)
  • Sorted by date (newest first)

Read Note

```bash
gesttalt note read [OPTIONS]
```

Options:

  • --dir <dir> - Project directory
  • --format <format> - Output format: markdown, json (default: markdown)

Behavior:

  • Finds note by timestamp or slug
  • Outputs full content or JSON representation

Update Note

```bash
gesttalt note update [OPTIONS]
```

Options:

  • --content <text> - Replace content
  • --slug <slug> - Set/update slug
  • --remove-slug - Remove slug override
  • --edit - Open in $EDITOR
  • --dir <dir> - Project directory

Behavior:

  • Finds note by timestamp or slug
  • Updates content or frontmatter
  • Preserves timestamp filename

Delete Note

```bash
gesttalt note delete [OPTIONS]
```

Options:

  • --dir <dir> - Project directory
  • --force - Skip confirmation prompt

Behavior:

  • Finds note by timestamp or slug
  • Prompts for confirmation (unless --force)
  • Deletes file

Implementation Notes

  • Commands should follow existing CLI patterns (clap library)
  • Reuse existing note loading/parsing infrastructure
  • Use std.time.timestamp() for current Unix timestamp
  • Support both timestamp and slug as identifiers for read/update/delete
  • Ensure proper error messages for missing notes, invalid IDs, etc.
  • Consider adding gesttalt note edit <id> as alias for update --edit

Timestamp Handling

  • Default to current timestamp: std.time.timestamp()
  • Allow custom timestamps for backdating notes
  • Validate timestamp is reasonable (not in far future, not before epoch)
  • Format display dates as ISO 8601 (YYYY-MM-DD HH:MM:SS)

Out of Scope

  • Batch operations (can be added later)
  • Note templates (can be added later)
  • Threading/replies (can be added later)
  • Media attachments (can be added later)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions