Class: Fastlane::Actions::RunClangFormatAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::RunClangFormatAction
- Defined in:
- lib/fastlane/plugin/clang_format/actions/run_clang_format.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(_platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
76 77 78 |
# File 'lib/fastlane/plugin/clang_format/actions/run_clang_format.rb', line 76 def self. ["Marcin Stepnowski"] end |
.available_options ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/clang_format/actions/run_clang_format.rb', line 41 def self. [ FastlaneCore::ConfigItem.new(key: :script_path, env_name: 'FL_RUN_CLANG_FORMAT_SCRIPT_PATH', description: 'Optional, you must specify the path to run-clang-format.py if it is not in the project root directory', optional: true, type: String), FastlaneCore::ConfigItem.new(key: :extensions, env_name: 'FL_RUN_CLANG_FORMAT_EXTENSIONS', description: 'Comma separated list of file extensions (default: c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx)', optional: true, type: String), FastlaneCore::ConfigItem.new(key: :recursive, env_name: 'FL_RUN_CLANG_FORMAT_RECURSIVE', description: 'Run recursively over directories', optional: true, default_value: true, type: Boolean), FastlaneCore::ConfigItem.new(key: :paths, env_name: 'FL_RUN_CLANG_FORMAT_PATHS', description: 'Array of path to check formatting', optional: false, type: Array), FastlaneCore::ConfigItem.new(key: :executable, env_name: 'FL_RUN_CLANG_FORMAT_EXECUTABLE', description: 'Path to the clang-format executable', optional: false, type: String) ] end |
.description ⇒ Object
28 29 30 |
# File 'lib/fastlane/plugin/clang_format/actions/run_clang_format.rb', line 28 def self.description 'Run clang format python script: https://github.com/Sarcasm/run-clang-format' end |
.details ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fastlane/plugin/clang_format/actions/run_clang_format.rb', line 32 def self.details [ 'A wrapper script around clang-format, suitable for linting multiple files and', 'to use for continuous integration. This is an alternative API for the clang-format', 'command line. It runs over multiple files and directories in parallel.', 'A diff output is produced and a sensible exit code is returned.' ].join(' ') end |
.is_supported?(_platform) ⇒ Boolean
72 73 74 |
# File 'lib/fastlane/plugin/clang_format/actions/run_clang_format.rb', line 72 def self.is_supported?(_platform) true end |
.run(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fastlane/plugin/clang_format/actions/run_clang_format.rb', line 6 def self.run(params) script_path = params[:script_path] script_path ||= Dir['run-clang-format.py'].first UI.user_error!('run-clang-format.py not found, add file or pass path to it') if script_path.to_s.empty? cmd = [] cmd << script_path extensions = params[:extensions] cmd << "--extensions" if extensions cmd << extensions if extensions clang_format_executable = params[:executable] cmd << "--clang-format-executable" if clang_format_executable cmd << clang_format_executable if clang_format_executable cmd << '-r' if params[:recursive] paths = params[:paths] Array(paths).each do |path| cmd << path end Actions.sh(Shellwords.join(cmd)) UI.success('Everything is formatted correctly, all good! 💪') end |