Sha256: 00c9034196fac2c1d88c3c8394c4544a880f015fce667b0989179e3f33f8bee0

Contents?: true

Size: 1.6 KB

Versions: 15

Compression:

Stored size: 1.6 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../lib/cpl"

commands_str_arr = []

commands = Command::Base.all_commands
commands.keys.sort.each do |command_key|
  command_class = commands[command_key]

  next if command_class::HIDE

  name = command_class::NAME
  usage = command_class::USAGE.empty? ? name : command_class::USAGE
  options = command_class::OPTIONS
  long_description = command_class::LONG_DESCRIPTION
  examples = command_class::EXAMPLES

  command_str = "### `#{name}`\n\n"
  command_str += "#{long_description.strip}\n\n"

  if examples.empty?
    options_str_arr = []
    options.each do |option|
      next unless option[:params][:required]

      options_str_arr.push("#{option[:params][:aliases][0]} $#{option[:params][:banner]}")
    end
    options_str = options_str_arr.join(" ")

    command_str += "```sh\ncpl #{usage}"
    command_str += " #{options_str}" unless options_str.empty?
    command_str += "\n```"
  else
    command_str += examples.strip
  end

  commands_str_arr.push(command_str)
end

commands_str = commands_str_arr.join("\n\n")

file_path = "#{__dir__}/../docs/commands.md"
file_data =
  <<~DATA
    <!-- NOTE: This file is automatically generated by running `script/generate_commands_docs`. Do NOT edit it manually. -->

    ## Common Options

    ```
    -a XXX, --app XXX         app ref on Control Plane (GVC)
    ```

    This `-a` option is used in most of the commands and will pick all other app configurations from the project-specific
    `.controlplane/controlplane.yml` file.

    ## Commands

    #{commands_str}
  DATA
File.binwrite(file_path, file_data)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cpl-2.2.4 script/update_command_docs
cpl-2.2.2 script/update_command_docs
cpl-2.2.1 script/update_command_docs
cpl-2.2.0 script/update_command_docs
cpl-1.4.0 script/update_command_docs
cpl-1.3.0 script/update_command_docs
cpl-1.2.0 script/update_command_docs
cpl-1.1.2 script/update_command_docs
cpl-1.1.2.rc.0 script/update_command_docs
cpl-1.1.1 script/update_command_docs
cpl-1.1.0 script/update_command_docs
cpl-1.0.4 script/update_command_docs
cpl-1.0.3 script/update_command_docs
cpl-1.0.2 script/update_command_docs
cpl-1.0.1 script/update_command_docs