Artistic Style 1.22
A Free, Fast and Small Automatic Formatter for C, C++, C#, and Java Source Code
Home Page: | http://astyle.sourceforge.net/ |
Project Page: | http://sourceforge.net/projects/astyle/ |
first give some example :
F:Linux_resourceastyletestfile>astyle -r test/*.c
————————————————–
directory test*.c
————————————————–
formatted nandas.c
formatted t2nandas2.c
formatted t2nandas4.c
formatted t2t3nandas3.c
F:Linux_resourceastyletestfile>astyle –style=ansi –mode=c -r test/*.c
————————————————–
directory test*.c
————————————————–
formatted nandas.c
formatted t2nandas2.c
formatted t2nandas4.c
formatted t2t3nandas3.c
F:Linux_resourceastyletestfile>astyle –style=kr –mode=c -r test/*.c
————————————————–
directory test*.c
————————————————–
formatted nandas.c
formatted t2nandas2.c
formatted t2nandas4.c
formatted t2t3nandas3.c
F:Linux_resourceastyletestfile>astyle –style=linux -r test/*.c
————————————————–
directory test*.c
————————————————–
formatted nandas.c
formatted t2nandas2.c
formatted t2nandas4.c
formatted t2t3nandas3.c
F:Linux_resourceastyletestfile>astyle –style=gnu –mode=c -r test/*.c
————————————————–
directory test*.c
————————————————–
formatted nandas.c
formatted t2nandas2.c
formatted t2nandas4.c
formatted t2t3nandas3.c
F:Linux_resourceastyletestfile>astyle -V
Artistic Style Version 1.22
simple explanation :
–style= gnu / linux / ansi /java ,these are predefined style ,we can use it directly ,very useful ones.
-r is –recursive or -R.
–mode= c / java / cs to destinate the source file format .
some useful info :
Usage
Artistic style is a console program that receives information from the command line. The format of the command line is:
astyle [options] <em>SourceFile1 SourceFile2 SourceFile3</em> [ . . . ]
Or to save the file with a different name:
astyle [options] < <em>OriginalSourceFile</em> > <em>BeautifiedSourceFile</em>
The < and > characters are used to redirect the files into standard input and out of standard output – don’t forget them!
The block parens [ ] indicate that more than one option or more than one filename can be entered. They are NOT actually included in the command. For the options format see the following Options section.
With the first option, the newly indented file retains the original file name, while a copy of the original file is created with an .orig
appended to the original file name. (This can be set to a different string by the option --suffix=
, or suppressed altogether by the options -n
or --suffix=none
). Thus, after indenting SourceFile1.cpp
as above, the indented result will be named SourceFile1.cpp
, while the original pre-indented file will be renamed to SourceFile1.cpp.orig
.
With the second option, the file is saved with a different name. Therefore a copy is not created.
Wildcards
(such as "*.cpp"), can be used if the project is compiled to include them. See the Installation Information for instructions.
Predefined Style Options
Predefined Style options define the style by setting several other options. If other options are also used, the placement of the predefined style option in the command line is important. If the predefined style option is placed first, the other options may override the predefined style. If placed last, the predefined style will override the other options.
For example the style –style=ansi sets the option –brackets=break. If the command line specifies "–style=ansi –brackets=attach", the brackets will be attached and the style will not be ansi style. If the order on the command line is reversed to "–brackets=attach –style=ansi ", the brackets will be broken (ansi style) and the attach option will be ignored.
For the options set by each style check the parseOption function in astyle_main.cpp.
Formatting Options
………..
--mode=c
Indent a C or C++ file. The option is usually set from the file extension for each file. You can override the setting with this entry. It will be used for all files regardless of the file extension. It allows the formatter to identify language specific syntax such as C++ classes, templates, and keywords.
--mode=java
Indent a Java file. The option is usually set from the file extension for each file. You can override the setting with this entry. It will be used for all files regardless of the file extension. It allows the formatter to identify language specific syntax such as Java class’s keywords.
--mode=cs
Indent a C sharp file. The option is usually set from the file extension for each file. You can override the setting with this entry. It will be used for all files regardless of the file extension. It allows the formatter to identify language specific syntax such as C sharp classes and keywords.
Other Options
more details please refer :
Download
Download the latest release from the file releases page. Get the file for the appropriate platform (Linux, Mac, OpenVMS, or Windows). Extract the compressed package and copy it to a work folder. Then follow the install instructions for the appropriate platform as described in the Install Information.
转载请注明:在路上 » astyle – a good code indenter/ formatter/ beautifier