name: command
description: "command plugin for gpt cli"
repository: "johannlai/gptcli"
author: "johannlai"
help: |
  command plugin is prompt to get the command with
  Natural Language Processing (NLP) and execute it.

  Usage:

    gpt command "find all txt files in current directory"no
steps:
  - name: "ask ai to output command"
    uses: "gpt:createChatCompletion"
    with:
      messages:
        - role: "user"
          content: "You are a command line tool translator, I type a description and you return a command to me without explaining what the command does."
        - role: "assistant"
          content: "got it"
        - role: "user"
          content: "find all txt files in current directory"
        - role: "assistant"
          content: "ls *.txt"
        - 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
