1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-08-04 14:43:38 +02:00

Modify 'repo list' command to use the new output module

This commit is contained in:
2023-05-30 09:08:53 +02:00
parent c8fad57151
commit e1e8128af9
2 changed files with 56 additions and 8 deletions

View File

@@ -0,0 +1,47 @@
Feature: `osc repo` command
Scenario: Run `osc repo` with no arguments
When I execute osc with args "repo"
Then stdout is
"""
"""
Scenario: Run `osc repo list` on a project
When I execute osc with args "repo list test:factory"
Then stdout is
"""
Repository : standard
Architectures : x86_64
i586
Paths : openSUSE.org:openSUSE:Tumbleweed/standard
"""
@destructive
Scenario: Run `osc repo add` on a project
When I execute osc with args "repo add --yes test:factory --repo=new-repo --arch=x86_64 --arch=aarch64 --path=test:factory/standard --path=test:devel/standard"
And I execute osc with args "repo list test:factory"
Then stdout is
"""
Repository : standard
Architectures : x86_64
i586
Paths : openSUSE.org:openSUSE:Tumbleweed/standard
Repository : new-repo
Architectures : x86_64
aarch64
Paths : test:factory/standard
test:devel/standard
"""
@destructive
Scenario: Run `osc repo remove` on a project
When I execute osc with args "repo remove --yes test:factory --repo=standard --repo=does-not-exist"
And I execute osc with args "repo list test:factory"
Then stdout is
"""
"""

View File

@@ -1,4 +1,5 @@
import osc.commandline
from ..output import KeyValueTable
from .._private.project import ProjectMeta
@@ -19,12 +20,12 @@ class RepoListCommand(osc.commandline.OscCommand):
def run(self, args):
meta = ProjectMeta.from_api(args.apiurl, args.project)
table = KeyValueTable()
for repo in meta.repository_list():
print(f"Repository: {repo['name']}")
print("Architectures:")
for arch in repo["archs"]:
print(f" {arch}")
print("Paths:")
for path in repo["paths"]:
print(f" {path['project']}/{path['repository']}")
print()
table.add("Repository", repo["name"], color="bold")
table.add("Architectures", ", ".join(repo["archs"]))
if repo["paths"]:
paths = [f"{path['project']}/{path['repository']}" for path in repo["paths"]]
table.add("Paths", paths)
table.newline()
print(str(table))