Skip to content

Commit b225a73

Browse files
committed
refactor: correct some help texts and printing of output
1 parent 209be88 commit b225a73

File tree

3 files changed

+17
-40
lines changed

3 files changed

+17
-40
lines changed

.vscode/launch.json

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,6 @@
1414
],
1515
"justMyCode": false
1616
},
17-
{
18-
"name": "Python: RobotCode.Runner",
19-
"type": "python",
20-
"request": "launch",
21-
"module": "robotcode.runner",
22-
"justMyCode": false,
23-
"cwd": "${workspaceFolder}/tests/robotcode/language_server/robotframework/parts/data",
24-
"args": [
25-
"tests1"
26-
]
27-
// "args": [
28-
// "-d",
29-
// "results",
30-
// "-P",
31-
// "./lib",
32-
// "-P",
33-
// "resources",
34-
// "-v",
35-
// "NAME:value",
36-
// "--dryrun",
37-
// "tests"
38-
// ]
39-
},
4017
{
4118
"name": "Python: RobotCode",
4219
"type": "python",
@@ -61,8 +38,9 @@
6138
// "--",
6239
// "--help"
6340
// "run"
64-
"--format", "json",
65-
"--no-color",
41+
//"--format", "json-indent",
42+
//"--no-color",
43+
//"--no-pager",
6644
"config", "info", "desc",
6745
// "discover",
6846
// "all",

packages/plugin/src/robotcode/plugin/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ def print_data(
141141
if self.config.colored_output == ColoredOutput.YES:
142142
self.warning('Package "rich" is required to use colored output.')
143143

144-
self.echo(text)
144+
if self.config.pager:
145+
self.echo_via_pager(text)
146+
else:
147+
self.echo(text)
145148

146149
return
147150

@@ -176,12 +179,14 @@ def __rich_console__(self, console: Console, options: ConsoleOptions) -> RenderR
176179

177180
Markdown.elements["heading_open"] = MyHeading
178181

182+
markdown = Markdown(text, justify="left", code_theme="default")
183+
179184
console = Console()
180185
if self.config.pager:
181-
with console.pager(styles=self.colored, links=self.colored):
182-
console.print(Markdown(text, justify="left"))
186+
with console.pager(styles=True, links=True):
187+
console.print(markdown)
183188
else:
184-
console.print(Markdown(text, justify="left"))
189+
console.print(markdown)
185190
return
186191
except ImportError:
187192
if self.config.colored_output == ColoredOutput.YES:

src/robotcode/cli/commands/config.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dataclasses
2-
import fnmatch
32
import os
3+
from fnmatch import fnmatchcase
44
from pathlib import Path
55
from typing import Any, Dict, List, Optional
66

@@ -87,7 +87,6 @@ def files(
8787
8888
\b
8989
Examples:
90-
9190
```
9291
robotcode config files
9392
robotcode config files tests/acceptance/first.robot
@@ -139,7 +138,6 @@ def root(
139138
140139
\b
141140
Examples:
142-
143141
```
144142
robotcode config root
145143
robotcode config root tests/acceptance/first.robot
@@ -218,7 +216,6 @@ def list(app: Application, name: Optional[List[str]] = None) -> None:
218216
219217
\b
220218
Examples:
221-
222219
```
223220
robotcode config info list
224221
robotcode config info list rebot.*
@@ -233,13 +230,13 @@ def list(app: Application, name: Optional[List[str]] = None) -> None:
233230
result = []
234231
for n in name:
235232
for field in config_fields.keys():
236-
if fnmatch.fnmatchcase(field, n):
233+
if fnmatchcase(field, n):
237234
result.append(field)
238235

239236
if app.config.output_format is None or app.config.output_format == OutputFormat.TEXT:
240237
app.echo_via_pager(os.linesep.join(result))
241238
else:
242-
app.print_data({"output": result})
239+
app.print_data({"names": result})
243240

244241

245242
@info.command()
@@ -254,7 +251,6 @@ def desc(app: Application, name: Optional[List[str]] = None) -> None:
254251
255252
\b
256253
Examples:
257-
258254
```
259255
robotcode config info desc
260256
robotcode config info desc python-path
@@ -266,9 +262,7 @@ def desc(app: Application, name: Optional[List[str]] = None) -> None:
266262
name = ["*"]
267263

268264
config_fields = [
269-
(field, value)
270-
for field, value in get_config_fields().items()
271-
if any(fnmatch.fnmatchcase(field, n) for n in name)
265+
(field, value) for field, value in get_config_fields().items() if any(fnmatchcase(field, n) for n in name)
272266
]
273267

274268
if app.config.output_format is None or app.config.output_format == OutputFormat.TEXT:
@@ -282,7 +276,7 @@ def desc(app: Application, name: Optional[List[str]] = None) -> None:
282276
else:
283277
app.print_data(
284278
{
285-
"output": [
279+
"descriptions": [
286280
{"name": field, "type": value["type"], "description": value["description"]}
287281
for field, value in config_fields
288282
]

0 commit comments

Comments
 (0)