name: weather
description: "weather plugin for gpt cli"
repository: "johannlai/gptcli"
author: "johannlai"
help: |
  weather plugin for gpt cli

  Usage:
    ❯ gpt weather "what's the weather in Paris, France?"

    Weather for City: Paris, France

     \   /     Clear
      .-.      10 – 11 °C
   ― (   ) ―   ↑ 11 km/h
      `-’      10 km
     /   \     0.0 mm

steps:
  - name: "ask ai to gen the weather curl command"
    uses: "gpt:createChatCompletion"
    with:
      messages:
        - role: "user"
          content: "You are a curl tool that generates the curl command to get the local weather from wttr.in when I input a sentence, without any explanation."
        - role: "assistant"
          content: "got it"
        - role: "user"
          content: "what's the weather in Paris, France?"
        - role: "assistant"
          content: curl 'wttr.in/Paris?format=3'
        - role: "user"
          content: $params_0
    export:
      response_content: COMMAND
  - name: "ask if user want to execute the command"
    uses: "gpt:confirm"
    with:
      message: "execute the command above ⬆️ ?"
      default: true
    export:
      answer: ANSWER
  - name: "execute the command"
    if: $ANSWER == true
    script: |
      $COMMAND
