class Fastlane::Actions::SwiftformatAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 50 def self.available_options [ FastlaneCore::ConfigItem.new(key: :executable, description: "Path to the `swiftformat` executable on your machine", is_string: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test? end), FastlaneCore::ConfigItem.new(key: :path, description: "Path to format", is_string: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test? end), FastlaneCore::ConfigItem.new(key: :rules, description: "Specify a whitelist of rules", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :disable, description: "Specify rules to disable", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :enable, description: "Specify rules to enable", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :swiftversion, description: "Specify swift version", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :config, description: "Path to configuration file", is_string: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test? end), FastlaneCore::ConfigItem.new(key: :dryrun, description: "Run in dry mode (without actually changing any files)", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :lint, description: "Like `--dryrun`, but returns an error if formatting is needed", is_string: false, optional: true) ] end
category()
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 130 def self.category :testing end
description()
click to toggle source
@!group Documentation
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 42 def self.description "Run swift code formatting using SwiftFormat" end
details()
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 46 def self.details "Run swift code formatting using [SwiftFormat](https://github.com/nicklockwood/SwiftFormat). Please specify your options using a `.swiftformat` file. An up-to-date list with all available rules can be found in [Rules.md](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md) along with documentation for how they are used." end
example_code()
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 114 def self.example_code [ 'swiftformat( executable: "Pods/SwiftFormat/CommandLineTool/swiftformat", # Path to the `swiftformat` executable on your machine (optional) path: "path/to/format", # Path to format (optional) rules: "indent,linebreaks", # Specify a whitelist of rules (optional) disable: "redundantSelf,trailingClosures", # Specify rules to disable (optional) enable: "isEmpty", # Specify rules to enable (optional) swiftversion: "5.1" # Specify swift version (optional) config: "path/to/configuration/.swiftformat" # Path to configuration file (optional) dryrun: false, # Run in dry mode (without actually changing any files) (optional) lint: true # Like `--dryrun`, but returns an error if formatting is needed (optional) )' ] end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 110 def self.is_supported?(platform) [:ios, :mac].include?(platform) end
output()
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 100 def self.output end
return_value()
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 103 def self.return_value end
run(params)
click to toggle source
# File lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb, line 7 def self.run(params) if `which swiftformat`.to_s.length == 0 && params[:executable].nil? && !Helper.test? UI.user_error!("You have to install swiftformat using `brew install swiftformat` or specify the executable path with the `:executable` option.") end command = "" if params[:executable] command << params[:executable] else command << "swiftformat" end if params[:path] command << " #{params[:path].shellescape}" else command << " ." end command << " --rules #{params[:rules].shellescape}" if params[:rules] command << " --disable #{params[:disable].shellescape}" if params[:disable] command << " --enable #{params[:enable].shellescape}" if params[:enable] command << " --swiftversion #{params[:swiftversion].shellescape}" if params[:swiftversion] command << " --config #{params[:config].shellescape}" if params[:config] command << " --dryrun" if params[:dryrun] command << " --lint" if params[:lint] Actions.sh(command) end