Sha256: cd274e962f657a15c245723931757efa28e9014b95143b349fa5f094e6deda33

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

# typed: strict
# frozen_string_literal: true

module Tapioca
  module Commands
    class Command
      extend T::Sig
      extend T::Helpers

      class FileWriter < Thor
        include Thor::Actions
      end

      include Thor::Base
      include CliHelper

      abstract!

      sig { void }
      def initialize
        @file_writer = T.let(FileWriter.new, Thor::Actions)
      end

      sig { abstract.void }
      def execute; end

      private

      sig { params(command: Symbol, args: String).returns(String) }
      def default_command(command, *args)
        [Tapioca::BINARY_FILE, command.to_s, *args].join(" ")
      end

      sig { returns(Thor::Actions) }
      attr_reader :file_writer

      sig do
        params(
          path: T.any(String, Pathname),
          content: String,
          force: T::Boolean,
          skip: T::Boolean,
          verbose: T::Boolean
        ).void
      end
      def create_file(path, content, force: true, skip: false, verbose: true)
        file_writer.create_file(path, force: force, skip: skip, verbose: verbose) { content }
      end

      sig do
        params(
          path: T.any(String, Pathname),
          verbose: T::Boolean
        ).void
      end
      def remove_file(path, verbose: true)
        file_writer.remove_file(path, verbose: verbose)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
tapioca-0.10.1 lib/tapioca/commands/command.rb
tapioca-0.10.0 lib/tapioca/commands/command.rb
tapioca-0.9.4 lib/tapioca/commands/command.rb
tapioca-0.9.3 lib/tapioca/commands/command.rb
tapioca-0.9.2 lib/tapioca/commands/command.rb
tapioca-0.9.1 lib/tapioca/commands/command.rb
tapioca-0.9.0 lib/tapioca/commands/command.rb
tapioca-0.8.3 lib/tapioca/commands/command.rb
tapioca-0.8.2 lib/tapioca/commands/command.rb
tapioca-0.7.3 lib/tapioca/commands/command.rb
tapioca-0.8.1 lib/tapioca/commands/command.rb
tapioca-0.8.0 lib/tapioca/commands/command.rb
tapioca-0.7.2 lib/tapioca/commands/command.rb
tapioca-0.7.1 lib/tapioca/commands/command.rb
tapioca-0.7.0 lib/tapioca/commands/command.rb