Skip to content

Allow adding text sources from files/STDIN in CLI #44

@K-dash

Description

@K-dash

Summary

nblm sources add only accepts inline --text arguments. Let users provide longer notes via --text-file path (and optionally --text-stdin) so they can reuse existing documents without copy/paste hassle.

Motivation

  • Research notes and transcripts often live in files; pasting them into the command line is error-prone.
  • Other CLI tools (e.g. gh, kubectl) support --*-file patterns, making automation easier.
  • Implementing this unlocks richer CLI workflows and makes the project more attractive to power users.

Tasks

  1. Extend crates/nblm-cli/src/ops/sources.rs to accept --text-file <PATH> (multiple allowed). Read each file, trim it, and push the content as UserContent::Text with an optional --text-name pairing.
  2. Optionally add --text-stdin that reads from standard input when present; ensure it can’t be combined with other stdin-consuming flags.
  3. Update docs/cli/sources.md with usage examples and note constraints (e.g. empty files should error).
  4. Add or update tests in crates/nblm-cli/tests/sources_add.rs to cover the new flags (use temp files in the test helper).

Verification

  • Run cargo test --package nblm-cli to ensure CLI tests pass.
  • Manual smoke test: cargo run -- sources add --notebook-id demo --text-file sample.txt using a known notebook ID and mock server/base URL.

Recommended for Contributors

  • You’ll need to touch both the CLI implementation and documentation, so be comfortable reading Rust and Markdown.
  • When reading files, surface friendly errors (e.g. file not found, unreadable). Follow existing error style (use anyhow::Context).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions