Command Line Formatter
Introduction
Command-line source code formatter is a special functionality within RubyMine that lets you format arbitrary files outside of a project. So doing, the formatter makes use of XML files with the exported code style settings ( ) and a file specification that defines a file or a group of files to be formatted.
For the files to be formatted there should be corresponding plugins which support the required file types.
Formatter launcher script
The script is format.bat/format.sh
(Windows/Linux,Mac) in <RubyMine_HOME>/bin
directory, where <RubyMine_HOME>
is RubyMine's root installation directory. The script launches RubyMine, which formats the specified files and quits. If launched without any parameters or with -h
parameter, the script outputs a list of its options.
Usage
format [-h] [-r|-R] [-s|-settings settingsPath] [-m|-mask masks] [path1 [path2]...]
Parameters
Parameter | Description |
---|---|
-h | Shows a help message and quits. |
-r|-R | Scans directories specified in path1,path2... recursively. |
-s|-settings settingsPath | settingsPath is a path to the file with the exported code style settings. |
-m|-mask masks | A comma-separated list of file masks, which define the files to be processed. The wildcard characters * (any string), ? (any single character) are supported. |
pathN | A path to a file or a directory to be processed. |
Example
1. Format all the files in C:\Data\src
directory, including all subdirectories, using the default code style settings:
format -r C:\Data\src
2. Non-recursively format all .java
and .html
files in C:\Data\src
directory, using code style settings from C:\Data\settings.xml
:
format -s C:\Data\settings.xml -m * .java,*.html C:\Data\src