NAntContrib Help Task Reference <astyle> | v0.85-nightly-2006-07-23 |
[This is preliminary documentation and subject to change.]
Formats source code in a given directory to a specified code format.
Most examples inline have been produced by Tal Davidson and team and are part of the astyle documentation. They have been included in the task documentation as an easy reference.
NOTE: This task relies on the astyle.exe file being in your path variable. Please download the astyle.exe from http://astyle.sourceforge.net.Attribute | Type | Description | Required |
---|---|---|---|
brackets-attach | bool | true if brackets should be attached. if (isFoo){ bar(); } else { anotherBar(); } | False |
brackets-linux | bool | true if brackets should be put on a new line and indented. namespace foospace { int Foo() { if (isBar) { bar(); return 1; } else return 0; } } | False |
brackets-newline | bool | true if brackets should be put on a new line. if (isFoo) { bar(); } else { anotherBar(); } | False |
break-blocks | bool | true to break block statements with an empty line. isFoo = true; if (isFoo) { bar(); } else { anotherBar(); } isBar = false; becomes: isFoo = true; if (isFoo) { bar(); } else { anotherBar(); } isBar = false; | False |
break-blocks-all | bool | true to break all block statements, even on nested ifs with an empty line. isFoo = true; if (isFoo) { bar(); } else { anotherBar(); } isBar = false; becomes: isFoo = true; if (isFoo) { bar(); } else { anotherBar(); } isBar = false; | False |
break-closing | bool | true if the line after a bracket (i.e. an else statement after the closing if) should be placed on the next line. if (isFoo){ bar(); }else { anotherBar(); } becomes: if (isFoo) { bar(); } else { anotherBar(); } | False |
break-elseif | bool | true to put the if component of an else if on a new line. if (isFoo) { bar(); } else if (isBar()){ anotherBar(); } becomes: if (isFoo) { bar(); } else if (isBar()){ anotherBar(); } | False |
cleanup | bool | Astyle leaves the original files around, renamed with a different suffix. Setting this to truewill remove these files. | False |
commandline | string | The command-line arguments for the program. | False |
convert-tabs | bool | true to convert tabs to spaces. | False |
fill-empty-lines | bool | true if empty lines should be filled with the whitespace of the previous line. | False |
indent-blocks | bool | true if block statements should be indented. The default: if (isFoo) { bar(); } else anotherBar(); becomes: if (isFoo) { bar(); } else anotherBar(); | False |
indent-brackets | bool | trueif bracket statements should be indented. The default: if (isFoo) { bar(); } else { anotherBar(); } becomes: if (isFoo) { bar(); } else { anotherBar(); } | False |
indent-cases | bool | true if case statements should be indented. The default: switch (foo) { case 1: { a += 2; break; } default: { a += 2; break; } } becomes: switch (foo) { case 1: { a += 2; break; } default: { a += 2; break; } } | False |
indent-classes | bool | true if class statements should be indented. The default: class Foo { public: Foo(); virtual ~Foo(); }; becomes: class Foo { public: Foo(); virtual ~Foo(); }; | False |
indent-labels | bool | true if label statements should be indented. The default: int foospace() { while (isFoo) { ... goto error; error: ... } } becomes: int foospace() { while (isFoo) { ... goto error; error: ... } } | False |
indent-max | int | Indicate the maximum number of spaces to indent relative to a previous line. | False |
indent-min | int | Indicate the maximum number of spaces to indent relative to a previous line. | False |
indent-namespaces | bool | true if namespace statements should be indented. The default: namespace foospace { class Foo { public: Foo(); virtual ~Foo(); }; } becomes: namespace foospace { class Foo { public: Foo(); virtual ~Foo(); }; } | False |
indent-num-spaces | int | Indicate the maximum number of spaces to indent relative to a previous line. | False |
indent-num-tabs | int | Indicate that tabs should be used to indent sources. The number specified indicates the maximum number of spaces the tab character will represent. | False |
indent-num-tabs-force | int | Indent using tab characters. Treat each tab as # spaces. Uses tabs as indents in areas '--indent=tab' prefers to use spaces, such as inside multi-line statements. | False |
indent-switches | bool | true if switch statements should be indented. The default: switch (foo) { case 1: a += 2; break; default: a += 2; break; } becomes: switch (foo) { case 1: a += 2; break; default: a += 2; break; } | False |
nobreak-complex | bool | true to keep complex statements on the same line. if (isFoo) { isFoo = false; cout << isFoo << endl; } remains as is. if (isFoo) DoBar(); remains as is. | False |
nobreak-singlelineblocks | bool | true to keep single line statements on the same line. if (isFoo) { isFoo = false; cout << isFoo << endl; } remains as is. | False |
pad-all | bool | true to pad operators and parenthesis. if (isFoo) a = bar((b-c)*a,*d--); becomes: if ( isFoo ) a = bar( ( b - c ) * a, *d-- ); | False |
pad-operators | bool | true to pad operators with a space. if (isFoo) a = bar((b-c)*a,*d--); becomes: if (isFoo) a = bar((b - c) * a, *d--); | False |
pad-parenthesis | bool | true to pad parenthesis with a space. if (isFoo) a = bar((b-c)*a,*d--); becomes: if ( isFoo ) a = bar( ( b-c )*a, *d-- ); | False |
style | string | Indicate the preset style to use. | False |
suffix | string | The suffix to append to original files, defaults to .orig if not specified. | False |
failonerror | bool | Determines if task failure stops the build, or is just reported. The default is true. | False |
if | bool | If true then the task will be executed; otherwise, skipped. The default is true. | False |
timeout | int | The maximum amount of time the application is allowed to execute, expressed in milliseconds. Defaults to no time-out. | False |
unless | bool | Opposite of if . If false then the task will be executed; otherwise, skipped. The default is false. | False |
verbose | bool | Determines whether the task should report detailed build log messages. The default is false. | False |
Attribute | Type | Description | Required |
---|---|---|---|
exename | string | The name of the executable that should be used to launch the external program. | False |
useruntimeengine | bool | Specifies whether the external program should be executed using a runtime engine, if configured. The default is false. | False |
Represents a command-line argument.
Attribute | Type | Description | Required |
---|---|---|---|
dir | directory | The value for a directory-based command-line argument; will be replaced with the absolute path of the directory. | False |
file | file | The name of a file as a single command-line argument; will be replaced with the absolute filename of the file. | False |
if | bool | Indicates if the argument should be passed to the external program. If true then the argument will be passed; otherwise, skipped. The default is true. | False |
line | string | List of command-line arguments; will be passed to the executable as is. | False |
path | <path> | The value for a PATH-like command-line argument; you can use : or ; as path separators and NAnt will convert it to the platform's local conventions, while resolving references to environment variables. | False |
unless | bool | Indicates if the argument should not be passed to the external program. If false then the argument will be passed; otherwise, skipped. The default is false. | False |
value | string | A single command-line argument; can contain space characters. | False |
A single command-line argument containing a space character.
<arg value="-l -a" />
Two separate command-line arguments.
<arg line="-l -a" />
A single command-line argument with the value \dir;\dir2;\dir3
on DOS-based systems and /dir:/dir2:/dir3
on Unix-like systems.
<arg path="/dir;/dir2:\dir3" />
<astyle style="NAnt" cleanup="true"> <sources> <include name="**/**.cs" /> </sources> </astyle>