Sha256: 004471be855ce17386a1412c5787a618778b59c2aa8cb7d40cb669f2a517023b

Contents?: true

Size: 1.35 KB

Versions: 4

Compression:

Stored size: 1.35 KB

Contents

module Pantograph
  module Actions
    class ClipboardAction < Action
      def self.run(params)
        value = params[:value]

        truncated_value = value[0..800].gsub(/\s\w+\s*$/, '...')
        UI.message("Storing '#{truncated_value}' in the clipboard 🎨")

        if PantographCore::Helper.mac?
          require 'open3'
          Open3.popen3('pbcopy') { |input, _, _| input << value }
        end
      end

      #####################################################
      # @!group Documentation
      #####################################################

      def self.description
        "Copies a given string into the clipboard. Works only on macOS"
      end

      def self.available_options
        [
          PantographCore::ConfigItem.new(key: :value,
                                       env_name: "FL_CLIPBOARD_VALUE",
                                       description: "The string that should be copied into the clipboard")
        ]
      end

      def self.authors
        ["KrauseFx", "joshdholtz"]
      end

      def self.is_supported?(platform)
        true
      end

      def self.example_code
        [
          'clipboard(value: "https://docs.pantograph.tools/")',
          'clipboard(value: lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK] || "")'
        ]
      end

      def self.category
        :misc
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pantograph-0.1.4 pantograph/lib/pantograph/actions/clipboard.rb
pantograph-0.1.3 pantograph/lib/pantograph/actions/clipboard.rb
pantograph-0.1.1 pantograph/lib/pantograph/actions/clipboard.rb
pantograph-0.1.0 pantograph/lib/pantograph/actions/clipboard.rb