Skip to content

Commit df14857

Browse files
committed
Use console_print, not print, for data output
1 parent 62b54b0 commit df14857

File tree

5 files changed

+62
-69
lines changed

5 files changed

+62
-69
lines changed

src/jgo/cli/commands/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,23 +210,23 @@ def _get_jgorc(config_file: Path, section: str, key: str, args: ParsedArgs) -> i
210210
# Get value based on section
211211
if section == "settings":
212212
if key == "cache_dir":
213-
print(settings.cache_dir)
213+
console_print(settings.cache_dir)
214214
elif key == "repo_cache":
215-
print(settings.repo_cache)
215+
console_print(settings.repo_cache)
216216
elif key == "links":
217-
print(settings.links)
217+
console_print(settings.links)
218218
else:
219219
_log.error(f"Unknown setting: {key}")
220220
return 1
221221
elif section == "repositories":
222222
if key in settings.repositories:
223-
print(settings.repositories[key])
223+
console_print(settings.repositories[key])
224224
else:
225225
_log.error(f"Repository '{key}' not found")
226226
return 1
227227
elif section == "shortcuts":
228228
if key in settings.shortcuts:
229-
print(settings.shortcuts[key])
229+
console_print(settings.shortcuts[key])
230230
else:
231231
_log.error(f"Shortcut '{key}' not found")
232232
return 1
@@ -254,7 +254,7 @@ def _get_toml(config_file: Path, section: str, key: str, args: ParsedArgs) -> in
254254
return 1
255255

256256
value = data[section][key]
257-
print(value)
257+
console_print(value)
258258
return 0
259259

260260

src/jgo/cli/commands/info.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import rich_click as click
99

1010
from ...parse.coordinate import Coordinate
11-
from ..console import console_print, get_color_mode
11+
from ..console import console_print
1212

1313
_log = logging.getLogger(__name__)
1414

@@ -80,7 +80,7 @@ def envdir(ctx, endpoint):
8080
ctx.exit(1)
8181
environment = builder.from_endpoint(endpoint, update=args.update)
8282

83-
print(environment.path)
83+
console_print(environment.path)
8484
ctx.exit(0)
8585

8686

@@ -327,7 +327,7 @@ def manifest(ctx, endpoint, raw):
327327
if manifest_content is None:
328328
_log.error(f"No MANIFEST.MF found in {jar_path}")
329329
ctx.exit(1)
330-
print(manifest_content, end="")
330+
console_print(manifest_content, end="")
331331
else:
332332
manifest_dict = parse_manifest(jar_path)
333333
if manifest_dict is None:
@@ -336,7 +336,7 @@ def manifest(ctx, endpoint, raw):
336336

337337
# Display parsed manifest
338338
for key, value in manifest_dict.items():
339-
print(f"{key}: {value}")
339+
console_print(f"{key}: {value}")
340340

341341
except SystemExit:
342342
raise
@@ -401,12 +401,7 @@ def pom(ctx, endpoint):
401401
# If pretty-printing fails, use raw content
402402
xml_output = pom_content
403403

404-
# Disable highlighting for plain mode
405-
# (Rich automatically disables syntax highlighting when piping in auto mode)
406-
use_highlighting = get_color_mode() != "plain"
407-
408-
# console_print auto-sets soft_wrap based on wrap mode
409-
console_print(xml_output, highlight=use_highlighting)
404+
console_print(xml_output)
410405

411406
except SystemExit:
412407
raise

src/jgo/cli/commands/versions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,21 @@ def execute(args: ParsedArgs, config: dict) -> int:
7171
# Get available versions
7272
metadata = project.metadata
7373
if not metadata or not metadata.versions:
74-
# Use rich() for styled output
7574
console_print(f"No versions found for {coord.rich()}")
7675
return 0
7776

7877
# Use project's smart release/latest resolution
7978
release_version = project.release
8079
latest_version = project.latest
8180

82-
# Data output - use str() for plain text (no Rich markup)
83-
print(f"Available versions for {coord}:")
81+
console_print(f"Available versions for {coord.rich()}:")
8482
for version in metadata.versions:
8583
marker = ""
8684
if release_version and version == release_version:
8785
marker = " (release)"
8886
elif latest_version and version == latest_version:
8987
marker = " (latest)"
90-
print(f" {version}{marker}")
88+
console_print(f" {version}[dim]{marker}[/]")
9189

9290
except Exception as e:
9391
_log.error(f"Error fetching versions: {e}")

src/jgo/cli/output.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def print_classpath(environment: Environment) -> None:
6868
)
6969
return
7070

71-
# Print one classpath element per line (raw output, no Rich formatting)
71+
# Print one classpath element per line
7272
for jar_path in class_path_jars:
73-
print(jar_path)
73+
console_print(jar_path)
7474

7575

7676
def print_modulepath(environment: Environment) -> None:
@@ -89,9 +89,9 @@ def print_modulepath(environment: Environment) -> None:
8989
)
9090
return
9191

92-
# Print one module-path element per line (raw output, no Rich formatting)
92+
# Print one module-path element per line
9393
for jar_path in module_jars:
94-
print(jar_path)
94+
console_print(jar_path)
9595

9696

9797
def print_jars(environment: Environment) -> None:
@@ -112,7 +112,7 @@ def print_jars(environment: Environment) -> None:
112112
if cp_jars:
113113
console_print("[bold cyan]Classpath:[/]")
114114
for jar_path in cp_jars:
115-
print(jar_path)
115+
console_print(jar_path)
116116
else:
117117
console_print("[yellow]No classpath JARs[/]")
118118

@@ -123,7 +123,7 @@ def print_jars(environment: Environment) -> None:
123123
else:
124124
console_print("[bold cyan]Module-path:[/]")
125125
for jar_path in mp_jars:
126-
print(jar_path)
126+
console_print(jar_path)
127127
else:
128128
console_print("[yellow]No module-path JARs[/]")
129129

tests/cli/info.t

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -180,49 +180,49 @@ Test info manifest with endpoint.
180180
Test info manifest --raw flag.
181181

182182
$ jgo info manifest --raw com.google.guava:guava:33.0.0-jre
183-
Manifest-Version: 1.0\r (esc)
184-
Automatic-Module-Name: com.google.common\r (esc)
185-
Build-Jdk-Spec: 11\r (esc)
186-
Bundle-Description: Guava is a suite of core and expanded libraries th\r (esc)
187-
at include utility classes, Google's collections, I/O classes, and\r (esc)
188-
much more.\r (esc)
189-
Bundle-DocURL: https://github.com/google/guava/\r (esc)
190-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt\r (esc)
191-
Bundle-ManifestVersion: 2\r (esc)
192-
Bundle-Name: Guava: Google Core Libraries for Java\r (esc)
193-
Bundle-SymbolicName: com.google.guava\r (esc)
194-
Bundle-Version: 33.0.0.jre\r (esc)
195-
Created-By: Apache Maven Bundle Plugin 5.1.8\r (esc)
196-
Export-Package: com.google.common.annotations;version="33.0.0",com.goo\r (esc)
197-
gle.common.base;version="33.0.0";uses:="javax.annotation",com.google.\r (esc)
198-
common.cache;version="33.0.0";uses:="com.google.common.base,com.googl\r (esc)
199-
e.common.collect,com.google.common.util.concurrent,javax.annotation",\r (esc)
200-
com.google.common.collect;version="33.0.0";uses:="com.google.common.b\r (esc)
201-
ase,javax.annotation",com.google.common.escape;version="33.0.0";uses:\r (esc)
202-
="com.google.common.base,javax.annotation",com.google.common.eventbus\r (esc)
203-
;version="33.0.0",com.google.common.graph;version="33.0.0";uses:="com\r (esc)
204-
.google.common.collect,javax.annotation",com.google.common.hash;versi\r (esc)
205-
on="33.0.0";uses:="com.google.common.base,javax.annotation",com.googl\r (esc)
206-
e.common.html;version="33.0.0";uses:="com.google.common.escape",com.g\r (esc)
207-
oogle.common.io;version="33.0.0";uses:="com.google.common.base,com.go\r (esc)
208-
ogle.common.collect,com.google.common.graph,com.google.common.hash,ja\r (esc)
209-
vax.annotation",com.google.common.math;version="33.0.0";uses:="javax.\r (esc)
210-
annotation",com.google.common.net;version="33.0.0";uses:="com.google.\r (esc)
211-
common.base,com.google.common.collect,com.google.common.escape,javax.\r (esc)
212-
annotation",com.google.common.primitives;version="33.0.0";uses:="com.\r (esc)
213-
google.common.base,javax.annotation",com.google.common.reflect;versio\r (esc)
214-
n="33.0.0";uses:="com.google.common.collect,com.google.common.io,java\r (esc)
215-
x.annotation",com.google.common.util.concurrent;version="33.0.0";uses\r (esc)
216-
:="com.google.common.base,com.google.common.collect,com.google.common\r (esc)
217-
.util.concurrent.internal,javax.annotation",com.google.common.xml;ver\r (esc)
218-
sion="33.0.0";uses:="com.google.common.escape"\r (esc)
219-
Import-Package: com.google.common.util.concurrent.internal;version="[1\r (esc)
220-
.0,2)",javax.annotation;resolution:=optional;version="[3.0,4)",javax.\r (esc)
221-
crypto;resolution:=optional,javax.crypto.spec;resolution:=optional,su\r (esc)
222-
n.misc;resolution:=optional\r (esc)
223-
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"\r (esc)
224-
Tool: Bnd-6.3.1.202206071316\r (esc)
225-
\r (esc)
183+
Manifest-Version: 1.0
184+
Automatic-Module-Name: com.google.common
185+
Build-Jdk-Spec: 11
186+
Bundle-Description: Guava is a suite of core and expanded libraries th
187+
at include utility classes, Google's collections, I/O classes, and
188+
much more.
189+
Bundle-DocURL: https://github.com/google/guava/
190+
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
191+
Bundle-ManifestVersion: 2
192+
Bundle-Name: Guava: Google Core Libraries for Java
193+
Bundle-SymbolicName: com.google.guava
194+
Bundle-Version: 33.0.0.jre
195+
Created-By: Apache Maven Bundle Plugin 5.1.8
196+
Export-Package: com.google.common.annotations;version="33.0.0",com.goo
197+
gle.common.base;version="33.0.0";uses:="javax.annotation",com.google.
198+
common.cache;version="33.0.0";uses:="com.google.common.base,com.googl
199+
e.common.collect,com.google.common.util.concurrent,javax.annotation",
200+
com.google.common.collect;version="33.0.0";uses:="com.google.common.b
201+
ase,javax.annotation",com.google.common.escape;version="33.0.0";uses:
202+
="com.google.common.base,javax.annotation",com.google.common.eventbus
203+
;version="33.0.0",com.google.common.graph;version="33.0.0";uses:="com
204+
.google.common.collect,javax.annotation",com.google.common.hash;versi
205+
on="33.0.0";uses:="com.google.common.base,javax.annotation",com.googl
206+
e.common.html;version="33.0.0";uses:="com.google.common.escape",com.g
207+
oogle.common.io;version="33.0.0";uses:="com.google.common.base,com.go
208+
ogle.common.collect,com.google.common.graph,com.google.common.hash,ja
209+
vax.annotation",com.google.common.math;version="33.0.0";uses:="javax.
210+
annotation",com.google.common.net;version="33.0.0";uses:="com.google.
211+
common.base,com.google.common.collect,com.google.common.escape,javax.
212+
annotation",com.google.common.primitives;version="33.0.0";uses:="com.
213+
google.common.base,javax.annotation",com.google.common.reflect;versio
214+
n="33.0.0";uses:="com.google.common.collect,com.google.common.io,java
215+
x.annotation",com.google.common.util.concurrent;version="33.0.0";uses
216+
:="com.google.common.base,com.google.common.collect,com.google.common
217+
.util.concurrent.internal,javax.annotation",com.google.common.xml;ver
218+
sion="33.0.0";uses:="com.google.common.escape"
219+
Import-Package: com.google.common.util.concurrent.internal;version="[1
220+
.0,2)",javax.annotation;resolution:=optional;version="[3.0,4)",javax.
221+
crypto;resolution:=optional,javax.crypto.spec;resolution:=optional,su
222+
n.misc;resolution:=optional
223+
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
224+
Tool: Bnd-6.3.1.202206071316
225+
226226

227227
Test info pom requires endpoint.
228228

0 commit comments

Comments
 (0)