|
18 | 18 |
|
19 | 19 |
|
20 | 20 | INCLUDE_EXT = ('.robot', '.resource') |
| 21 | +HELP_MSG = f""" |
| 22 | +Version: {__version__} |
| 23 | +
|
| 24 | +Robotidy is a tool for formatting Robot Framework source code. |
| 25 | +See examples at the end of this help message too see how you can use Robotidy. |
| 26 | +For more documentation check README section at https://github.com/MarketSquare/robotframework-tidy |
| 27 | +""" |
| 28 | +EPILOG = """ |
| 29 | +Examples: |
| 30 | + # Format `path/to/src.robot` file |
| 31 | + $ robotidy path/to/src.robot |
| 32 | +
|
| 33 | + # Format every Robot Framework file inside `dir_name` directory |
| 34 | + $ robotidy dir_name |
| 35 | +
|
| 36 | + # List available transformers: |
| 37 | + $ robotidy --list-transformers |
| 38 | + |
| 39 | + # Display transformer documentation |
| 40 | + $ robotidy --describe-transformer <TRANSFORMER_NAME> |
| 41 | +
|
| 42 | + # Format `src.robot` file using `SplitTooLongLine` transformer only |
| 43 | + $ robotidy --transform SplitTooLongLine src.robot |
| 44 | +
|
| 45 | + # Format `src.robot` file using `SplitTooLongLine` transformer only and configured line length 140 |
| 46 | + $ robotidy --transform SplitTooLongLine:line_length=140 src.robot |
| 47 | +
|
| 48 | +""" |
| 49 | + |
| 50 | + |
| 51 | +class RawHelp(click.Command): |
| 52 | + def format_help_text(self, ctx, formatter): |
| 53 | + if self.help: |
| 54 | + formatter.write_paragraph() |
| 55 | + for line in self.help.split('\n'): |
| 56 | + formatter.write_text(line) |
| 57 | + |
| 58 | + def format_epilog(self, ctx, formatter): |
| 59 | + if self.epilog: |
| 60 | + formatter.write_paragraph() |
| 61 | + for line in self.epilog.split('\n'): |
| 62 | + formatter.write_text(line) |
21 | 63 |
|
22 | 64 |
|
23 | 65 | class TransformType(click.ParamType): |
@@ -142,7 +184,7 @@ def get_paths(src: Tuple[str, ...]): |
142 | 184 | return sources |
143 | 185 |
|
144 | 186 |
|
145 | | -@click.command() |
| 187 | +@click.command(cls=RawHelp, help=HELP_MSG, epilog=EPILOG) |
146 | 188 | @click.option( |
147 | 189 | '--transform', |
148 | 190 | type=TransformType(), |
|
0 commit comments