Sha256: 324077f67cecefa54b32f5a57808b72ba03697dadbbbda24d0c317f00fbdfbf6

Contents?: true

Size: 918 Bytes

Versions: 24

Compression:

Stored size: 918 Bytes

Contents

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

command_name = ARGV[0]&.downcase

abort("ERROR: Must provide command name.") unless command_name

file_name = command_name.gsub(/[^A-Za-z]/, "_")
file_path = "#{__dir__}/../lib/command/#{file_name}.rb"

abort("ERROR: Command '#{command_name}' already exists.") if File.exist?(file_path)

class_name = file_name.split("_").map(&:capitalize).join

file_data =
  <<~DATA
    # frozen_string_literal: true

    module Command
      class #{class_name} < Base
        # See `base.rb` for other constants to add here
        NAME = "#{command_name}"
        OPTIONS = [
          # Add options here
        ].freeze
        DESCRIPTION = "Add description here"
        LONG_DESCRIPTION = <<~DESC
          - Add long description here
        DESC

        def call
          # Add command logic here
        end
      end
    end
  DATA
File.binwrite(file_path, file_data)

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
cpflow-4.0.1 script/add_command
cpflow-4.0.0 script/add_command
cpflow-3.0.1 script/add_command
cpflow-3.0.0 script/add_command
cpl-2.2.4 script/add_command
cpl-2.2.2 script/add_command
cpl-2.2.1 script/add_command
cpl-2.2.0 script/add_command
cpl-1.4.0 script/add_command
cpl-1.3.0 script/add_command
cpl-1.2.0 script/add_command
cpl-1.1.2 script/add_command
cpl-1.1.2.rc.0 script/add_command
cpl-1.1.1 script/add_command
cpl-1.1.0 script/add_command
cpl-1.0.4 script/add_command
cpl-1.0.3 script/add_command
cpl-1.0.2 script/add_command
cpl-1.0.1 script/add_command
cpl-1.0.0 script/add_command