Add named templates with interactive prompts for `jp query`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16
- Forks
- 3
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 121
Description
Add support for named templates that can be defined in configuration files and used with interactive prompts for missing template variables.
Context
Currently, jp query supports basic templating with the --template flag, where template variables are resolved from the template.values configuration. However, users must manually configure all template values in advance, and there's no way to define reusable named templates.
This enhancement would allow users to define named templates in their configuration files and use them with a simple command like jp query --template <template_name>. When template variables are not pre-configured, the system would interactively prompt the user to provide values using the existing inquire crate integration.
Alternatives
Users can currently work around this by:
- Pre-defining all template values in
template.valuesconfig - Using the existing
--templateflag with manually crafted queries - Creating shell scripts or aliases to wrap common query patterns
However, these alternatives require more setup and don't provide the interactive experience that would make templates truly user-friendly.
Proposed Implementation
Extend the existing template system to support named templates stored in configuration files. Add a new CLI flag --template-field=key=value to allow setting template variables directly from the command line. When template variables are undefined, use the inquire crate to prompt users interactively.
The implementation would involve:
- Adding a
templatessection to the configuration schema - Modifying the query command to accept template names
- Integrating interactive prompts for undefined variables
- Supporting both CLI-provided and config-provided template values
Tasks
Extend the Template configuration struct to support named templates
- Add
--template-fieldCLI argument parsing to the query command - Integrate
inquireprompts for missing template variables - Update template rendering logic to handle named templates
- Add configuration file examples and documentation
Resources
blob/main/crates/jp_config/src/template.rs
blob/main/crates/jp_cli/src/cmd/query.rs#L28-L66
blob/main/crates/jp_cli/src/cmd/query.rs#L295-L305
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading crates/jp_config/src/template.rs and the query command sections at crates/jp_cli/src/cmd/query.rs#L28-L66 and #L295-L305. Trace the existing template configuration, --template handling, and inquire integration before deciding how named templates and --template-field should fit together. Done means configuration examples, named-template rendering, CLI-provided values, and prompts for missing variables are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100