Provide code syntax hints/mappings for file extensions
Sort of inline with https://github.com/raphaelmansuy/code2prompt/issues/9 to add a feature to allow users to pair custom file extensions with specific code syntax highlighting.
Right now for my code base, I see code2prompt has a lot of wrapped code in unknown syntax highlighting
```unknown
For example, maybe there's a way to tell code2prompt that *.inc extension files have bash shell scripting so when it comes across *.inc extension files code it wraps it in
```bash
Wasn't sure about how that would be done so asked ChatGPT4o 🤓
- Define a Command Line Argument for Mappings: Introduce a new command line argument, such as
--syntax-map, which takes a list of mappings. - Specify Mappings in a Clear Format: Use a simple and clear format for specifying each mapping, for example,
extension:syntax. - Handle Multiple Mappings: Allow users to specify multiple mappings separated by a comma or provide multiple
--syntax-maparguments.
code2prompt --syntax-map "inc:bash,customext:python,ext2:javascript"
Added in the roadmap.
Will be released soon
I see the readme has this updated usage example but --help for 0.8.1 doesn't show it from pipx install? and --analyze option is gone worked on 0.6.x versions
code2prompt --analyze --path $projectdir --gitignore $gitignoredir --suppress-comments --tokens --encoding $encoding --case-sensitive --output project_summary_analyze.md
Usage: code2prompt [OPTIONS] COMMAND [ARGS]...
Try 'code2prompt --help' for help.
Error: No such option: --analyze
pipx install code2prompt --force
Installing to existing venv 'code2prompt'
installed package code2prompt 0.8.1, installed using Python 3.9.20
These apps are now globally available
- code2prompt
done! ✨ 🌟 ✨
code2prompt --help
Usage: code2prompt [OPTIONS] COMMAND [ARGS]...
code2prompt CLI tool
Options:
-v, --version Show the version and exit.
--config FILE Path to configuration file
-p, --path PATH Path(s) to the directory or file to process.
-o, --output PATH Name of the output Markdown file.
-g, --gitignore PATH Path to the .gitignore file.
-f, --filter TEXT Comma-separated filter patterns to include
files (e.g., "*.py,*.js").
-i, --interactive Interactive mode to select files.
-e, --exclude TEXT Comma-separated patterns to exclude files
(e.g., "*.txt,*.md").
--case-sensitive Perform case-sensitive pattern matching.
-s, --suppress-comments Strip comments from the code files.
-ln, --line-number Add line numbers to source code blocks.
--no-codeblock Disable wrapping code inside markdown code
blocks.
-t, --template PATH Path to a Jinja2 template file for custom
prompt generation.
--tokens Display the token count of the generated
prompt.
--encoding [cl100k_base|p50k_base|p50k_edit|r50k_base]
Specify the tokenizer encoding to use.
--create-templates Create a templates directory with example
templates.
--log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
Set the logging level.
--price Display the estimated price of tokens based
on provider and model.
--provider TEXT Specify the provider for price calculation.
--model TEXT Specify the model for price calculation.
--output-tokens INTEGER Specify the number of output tokens for
price calculation.
--help Show this message and exit.
Commands:
analyze Analyze codebase structure
generate Generate markdown from code files