Sha256: 4dd228c686fe372520bc55d2d896789bc9ebb726ff569e3552750904063ad9af

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require_relative "../command"

module Snowpack
  module CLI
    module Application
      class Command < Snowpack::CLI::Command
        def self.inherited(klass)
          super

          klass.option :env, aliases: ["-e"], default: nil, desc: "Application environment"
        end

        attr_reader :application

        def initialize(application: nil, **opts)
          super(**opts)
          @application = application
        end

        # TODO: inject application inflector
        def with_application(application)
          self.class.new(
            command_name: @command_name,
            application: application,
            out: out,
            files: files,
          )
        end

        private

        def run_command(klass, *args)
          klass.new(
            command_name: klass.name,
            application: application,
            out: out,
            files: files,
          ).call(*args)
        end

        def measure(desc, &block)
          start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
          block.call
          stop = Process.clock_gettime(Process::CLOCK_MONOTONIC)

          out.puts "=> #{desc} in #{(stop - start).round(1)}s"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
snowpack-1.0.0.alpha7 lib/snowpack/cli/application/command.rb
snowpack-1.0.0.alpha6 lib/snowpack/cli/application/command.rb
snowpack-1.0.0.alpha5 lib/snowpack/cli/application/command.rb
snowpack-1.0.0.alpha4 lib/snowpack/cli/application/command.rb
snowpack-1.0.0.alpha3 lib/snowpack/cli/application/command.rb
snowpack-1.0.0.alpha2 lib/snowpack/cli/application/command.rb