Skip to content

feat: add text input support#24

Merged
chaliy merged 5 commits into
mainfrom
claude/add-text-input-support-OYbJI
Jan 10, 2026
Merged

feat: add text input support#24
chaliy merged 5 commits into
mainfrom
claude/add-text-input-support-OYbJI

Conversation

@chaliy
Copy link
Copy Markdown
Owner

@chaliy chaliy commented Jan 10, 2026

What

Add support for direct text input to generate and image commands without requiring a file. Input can now be provided as:

  • Positional argument: trickery generate "Your prompt here"
  • Flag argument: trickery generate -i "Your prompt here"
  • File path (existing behavior): trickery generate prompt.txt

The input is auto-detected: if the value is an existing file path, it reads the file; otherwise, it treats it as direct text.

Why

Users often want to run quick one-off prompts without creating temporary files. This is especially useful in CI/CD pipelines and shell scripts where inline prompts are more convenient.

How

  • Added resolve_input() function that checks if input path exists (reads file) or not (uses as text)
  • Implemented dual input capture with positional and -i flag arguments
  • Updated generate_output_filename() to handle text input (defaults to "image" stem)
  • Added override_usage for cleaner help display showing [INPUT] [OPTIONS]

Risk

  • Low
  • Existing file-based workflows unchanged; auto-detection only falls back to text if path doesn't exist

Checklist

  • Unit tests are passed
  • Smoke tests are passed
  • Documentation is updated (specs/text-input.md, test_cases/text_input.md)

Add -t/--text option to generate and image commands as alternative
to --input file. Enables:
- Quick one-off generations without temp files
- Long multi-line prompts via shell quoting
- Template variables work with text input

Changes:
- Add --text option to GenerateArgs and ImageArgs
- Validate mutually exclusive --input/--text (one required)
- Update generate_output_filename to handle no input file
- Add comprehensive documentation in help --full
- Add specs/text-input.md specification
- Add test_cases/text_input.md smoke tests
- Add unit tests for CLI parsing with --text
Simplify input handling by using single --input option that auto-detects:
- If value exists as file path: reads from file
- Otherwise: uses value as direct prompt text

Removes separate --text option in favor of unified approach.
Updates specs, test cases, help documentation, and unit tests.
Input can now be provided as positional arg or -i flag:
  trickery generate "Write a haiku"
  trickery generate -i "Write a haiku"

Both work identically with auto-detection of file vs text.
Updates help, specs, test cases, and unit tests.
- Add value_name="INPUT" to show [INPUT] instead of [INPUT_POSITIONAL]
- Add override_usage to show [INPUT] before [OPTIONS] in usage line
Replace -i flag with positional argument syntax throughout:
- README.md and prompts/trickery_readme.md
- docs/images.md and docs/image-generation.md
- specs/text-input.md
- All test case files
- src/main.rs help examples

Positional is now the preferred syntax, with -i kept for
backwards compatibility only.
@chaliy chaliy force-pushed the claude/add-text-input-support-OYbJI branch from 3da77ea to e286011 Compare January 10, 2026 06:34
@chaliy chaliy merged commit 27500e8 into main Jan 10, 2026
1 check passed
@chaliy chaliy deleted the claude/add-text-input-support-OYbJI branch January 10, 2026 06:39
chaliy added a commit that referenced this pull request May 30, 2026
## What
Add support for direct text input to `generate` and `image` commands
without requiring a file. Input can now be provided as:
- Positional argument: `trickery generate "Your prompt here"`
- Flag argument: `trickery generate -i "Your prompt here"`
- File path (existing behavior): `trickery generate prompt.txt`

The input is auto-detected: if the value is an existing file path, it
reads the file; otherwise, it treats it as direct text.

## Why
Users often want to run quick one-off prompts without creating temporary
files. This is especially useful in CI/CD pipelines and shell scripts
where inline prompts are more convenient.

## How
- Added `resolve_input()` function that checks if input path exists
(reads file) or not (uses as text)
- Implemented dual input capture with positional and `-i` flag arguments
- Updated `generate_output_filename()` to handle text input (defaults to
"image" stem)
- Added `override_usage` for cleaner help display showing `[INPUT]
[OPTIONS]`

## Risk
- Low
- Existing file-based workflows unchanged; auto-detection only falls
back to text if path doesn't exist

### Checklist
- [x] Unit tests are passed
- [x] Smoke tests are passed
- [x] Documentation is updated (specs/text-input.md,
test_cases/text_input.md)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants