Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color output for filter and format fileds in buildspec cache #1295

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions buildtest/cli/buildspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,35 +930,33 @@ def print_invalid_buildspecs(self, error=None, terse=None, header=None):
pprint(value)
sys.exit(1)

@staticmethod
def print_filter_fields():
def print_filter_fields(self):
"""This method prints filter fields available for buildspec cache. This
method implements command ``buildtest buildspec find --helpfilter``
"""

table = Table(
title="Filter Field Description", header_style="blue", show_lines=True
)
table.add_column("Field", style="red", overflow="fold")
table.add_column("Type", style="green", overflow="fold")
table.add_column("Description", style="cyan", overflow="fold")
table.add_column("Field", style=self.color, overflow="fold")
table.add_column("Type", style=self.color, overflow="fold")
table.add_column("Description", style=self.color, overflow="fold")

table.add_row("buildspecs", "Filter tests by buildspec", "FILE")
table.add_row("executor", "Filter by executor name", "STRING")
table.add_row("tags", "Filter by tag name ", "STRING")
table.add_row("type", "Filter by schema type ", "STRING")
console.print(table)

@staticmethod
def print_format_fields():
def print_format_fields(self):
"""This method prints format fields available for buildspec cache. This
method implements command ``buildtest buildspec find --helpformat``
"""
table = Table(
title="Format Field Description", header_style="blue", show_lines=True
)
table.add_column("Field", style="red", overflow="fold")
table.add_column("Description", style="green", overflow="fold")
table.add_column("Field", style=self.color, overflow="fold")
table.add_column("Description", style=self.color, overflow="fold")

table.add_row("buildspec", "Display name of buildspec file")
table.add_row("description", "Show description of test")
Expand All @@ -973,14 +971,14 @@ def print_raw_filter_fields(self):
method implements command ``buildtest buildspec find --filterfields``
"""
for field in self.filter_fields:
console.print(field)
console.print(f"[{self.color}]{field}")
prathmesh4321 marked this conversation as resolved.
Show resolved Hide resolved

def print_raw_format_fields(self):
"""This method prints the raw format fields available for buildspec cache. This
method implements command ``buildtest buildspec find --formatfields``
"""
for field in self.format_fields:
console.print(field)
console.print(f"[{self.color}]{field}")
prathmesh4321 marked this conversation as resolved.
Show resolved Hide resolved

def print_paths(self):
"""This method print buildspec paths, this implements command ``buildtest buildspec find --paths``"""
Expand Down
4 changes: 4 additions & 0 deletions tests/cli/test_buildspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def test_func_buildspec_find():
cache.print_tags()
cache.print_by_executors()
cache.print_by_tags()
cache.print_filter_fields()
cache.print_format_fields()
cache.print_raw_filter_fields()
cache.print_raw_format_fields()


@pytest.mark.cli
Expand Down