Skip to content

Commit 44ccc6e

Browse files
authored
Merge pull request #45 from MarketSquare/extend_help
Extend help message
2 parents 787c158 + 9a11c28 commit 44ccc6e

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

robotidy/cli.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,48 @@
1818

1919

2020
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)
2163

2264

2365
class TransformType(click.ParamType):
@@ -142,7 +184,7 @@ def get_paths(src: Tuple[str, ...]):
142184
return sources
143185

144186

145-
@click.command()
187+
@click.command(cls=RawHelp, help=HELP_MSG, epilog=EPILOG)
146188
@click.option(
147189
'--transform',
148190
type=TransformType(),

0 commit comments

Comments
 (0)