In this lesson, we enhance our Vibe application by adding two essential CLI flags using Cobra. First, we implement a `--prompt` flag that allows users to provide additional context to the AI model, such as "please make use of emojis to spice things up." We carefully integrate this into the ChatGPT provider's system message while ensuring users can't override the AI's primary role. Testing confirms the prompt works as intended—adding emojis when requested—while maintaining security against prompt injection attempts.
Next, we add a `--provider` flag to switch between ChatGPT and Ollama providers. We implement this using a provider function type and a switch statement, making the code easily extensible for future providers. During testing, we encounter an issue where Ollama sometimes hangs indefinitely, so we add a 10-second timeout using context.WithTimeout to prevent the application from getting stuck. The lesson concludes with both flags working smoothly, allowing users to customize their commit message generation experience while maintaining reliability.