Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #198 from RedHatProductSecurity/fix-text-crop
Browse files Browse the repository at this point in the history
GRIF-73: add terminal --width option
  • Loading branch information
JimFuller-RedHat authored May 29, 2023
2 parents 4833fa9 + ce663dc commit e871627
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- add terminal --width flag
### Changed
- bumped python requests module in tests, dev and lint requirements to address vuln

Expand Down
13 changes: 12 additions & 1 deletion griffon/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ def plugins_grp(ctx):
@click.option("--no-progress-bar", is_flag=True, help="Disable progress bar.")
@click.option("--no-color", is_flag=True, help="Disable output of color ansi esc sequences.")
@click.option("--no-wrap", is_flag=True, help="Disable wrapping of text output.")
@click.option(
"--width",
"terminal_width",
default=get_config_option("default", "terminal_width", 1000),
help="Terminal width (default is 1000).",
)
@click.option(
"--profile",
"profile",
Expand All @@ -122,7 +128,9 @@ def plugins_grp(ctx):
)
@click.option("--editor/--no-editor", default=True, help="Allow text editor prompt.")
@click.pass_context
def cli(ctx, debug, format, verbose, no_progress_bar, no_color, no_wrap, profile, editor):
def cli(
ctx, debug, format, verbose, no_progress_bar, no_color, no_wrap, terminal_width, profile, editor
):
"""Red Hat product security CLI"""

if ctx.invoked_subcommand is None:
Expand All @@ -145,6 +153,9 @@ def cli(ctx, debug, format, verbose, no_progress_bar, no_color, no_wrap, profile
ctx.obj["NO_WRAP"] = get_config_option("default", "no_wrap", False)
if no_wrap:
ctx.obj["NO_WRAP"] = no_wrap
ctx.obj["TERMINAL_WIDTH"] = get_config_option("default", "width", 1000)
if terminal_width:
ctx.obj["TERMINAL_WIDTH"] = terminal_width
ctx.obj["PROFILE"] = profile
ctx.obj["SHORT_VERSION_VALUES"] = True
ctx.obj["EDITOR"] = editor
Expand Down
2 changes: 2 additions & 0 deletions griffon/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,8 @@ def cprint(
format = OUTPUT_FORMAT(ctx.obj["FORMAT"])
if format is OUTPUT_FORMAT.TEXT:
no_wrap = ctx.obj["NO_WRAP"]
terminal_width = ctx.obj["TERMINAL_WIDTH"]
console.width = int(terminal_width)
if ctx.info_name == "product-summary":
text_output_product_summary(ctx, output, format, exclude_products, no_wrap=no_wrap)
if ctx.info_name == "products-contain-component":
Expand Down
3 changes: 2 additions & 1 deletion griffon/static/default_griffonrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ format = text
history_log = ~/.griffon/history.log
profile = default
verbosity = 0
no_wrap = True
no_wrap = False
terminal_width = 1000
sfm2_api_url = http://localhost:5600
custom_plugin_dir = ~/.griffon/plugins/
editor = vi
Expand Down

0 comments on commit e871627

Please sign in to comment.