Sha256: 660ca1d1816f2f5789995fa1bb71bbd9cc2762f8014a7f05dfe92133d35a4b00

Contents?: true

Size: 819 Bytes

Versions: 59

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

require 'zaru'
require 'fileutils'

module Superbot
  module CLI
    class NewCommand < Clamp::Command
      parameter "PATH", "path name to create" do |path|
        unless path == Zaru.sanitize!(path)
          raise ArgumentError, "#{path} is not valid name for a directory"
        end

        if Dir.exist? path
          raise ArgumentError, "directory #{path} already exists"
        end

        if File.exist? path
          raise ArgumentError, "#{path} is an existing file"
        end

        path
      end

      def execute
        FileUtils.mkdir path
        File.write File.join(path, "main.rb"), "visit \"http://example.com\"\n"

        puts """🤖 created directory #{path} with main.rb

Start testing with:

  superbot run #{path}
"""
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
superbot-0.5.3 lib/superbot/cli/new_command.rb
superbot-0.5.2 lib/superbot/cli/new_command.rb
superbot-0.5.1 lib/superbot/cli/new_command.rb
superbot-0.5.0 lib/superbot/cli/new_command.rb
superbot-0.4.9 lib/superbot/cli/new_command.rb
superbot-0.4.8 lib/superbot/cli/new_command.rb
superbot-0.4.7 lib/superbot/cli/new_command.rb
superbot-0.4.6 lib/superbot/cli/new_command.rb
superbot-0.4.5 lib/superbot/cli/new_command.rb
superbot-0.4.4 lib/superbot/cli/new_command.rb
superbot-0.4.3 lib/superbot/cli/new_command.rb
superbot-0.4.2 lib/superbot/cli/new_command.rb
superbot-0.4.1 lib/superbot/cli/new_command.rb
superbot-0.4.0 lib/superbot/cli/new_command.rb
superbot-0.3.7 lib/superbot/cli/new_command.rb
superbot-0.3.6 lib/superbot/cli/new_command.rb
superbot-0.3.5 lib/superbot/cli/new_command.rb
superbot-0.3.4 lib/superbot/cli/new_command.rb
superbot-0.3.3 lib/superbot/cli/new_command.rb
superbot-0.3.2 lib/superbot/cli/new_command.rb