1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-08-22 14:38:53 +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 import osc.commandline
from ..output import KeyValueTable
from .._private.project import ProjectMeta from .._private.project import ProjectMeta
@@ -19,12 +20,12 @@ class RepoListCommand(osc.commandline.OscCommand):
def run(self, args): def run(self, args):
meta = ProjectMeta.from_api(args.apiurl, args.project) meta = ProjectMeta.from_api(args.apiurl, args.project)
table = KeyValueTable()
for repo in meta.repository_list(): for repo in meta.repository_list():
print(f"Repository: {repo['name']}") table.add("Repository", repo["name"], color="bold")
print("Architectures:") table.add("Architectures", ", ".join(repo["archs"]))
for arch in repo["archs"]: if repo["paths"]:
print(f" {arch}") paths = [f"{path['project']}/{path['repository']}" for path in repo["paths"]]
print("Paths:") table.add("Paths", paths)
for path in repo["paths"]: table.newline()
print(f" {path['project']}/{path['repository']}") print(str(table))
print()