Class: Fastlane::Actions::ClipboardAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/clipboard.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



32
33
34
# File 'fastlane/lib/fastlane/actions/clipboard.rb', line 32

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

.available_optionsObject



24
25
26
27
28
29
30
# File 'fastlane/lib/fastlane/actions/clipboard.rb', line 24

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

.categoryObject



47
48
49
# File 'fastlane/lib/fastlane/actions/clipboard.rb', line 47

def self.category
  :misc
end

.descriptionObject



20
21
22
# File 'fastlane/lib/fastlane/actions/clipboard.rb', line 20

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

.example_codeObject



40
41
42
43
44
45
# File 'fastlane/lib/fastlane/actions/clipboard.rb', line 40

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

.is_supported?(platform) ⇒ Boolean

Returns:



36
37
38
# File 'fastlane/lib/fastlane/actions/clipboard.rb', line 36

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'fastlane/lib/fastlane/actions/clipboard.rb', line 4

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 FastlaneCore::Helper.mac?
    require 'open3'
    Open3.popen3('pbcopy') { |input, _, _| input << value }
  end
end