mirror of
https://github.com/openSUSE/osc.git
synced 2025-11-01 12:02:16 +01:00
Improve help of the 'git-obs login' subcommands
This commit is contained in:
@@ -9,17 +9,17 @@ Background:
|
|||||||
Default : true
|
Default : true
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Admin
|
User : Admin
|
||||||
SSH Key : {context.fixtures}/ssh-keys/admin
|
Private SSH key path : {context.fixtures}/ssh-keys/admin
|
||||||
|
|
||||||
Name : alice
|
Name : alice
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Alice
|
User : Alice
|
||||||
SSH Key : {context.fixtures}/ssh-keys/alice
|
Private SSH key path : {context.fixtures}/ssh-keys/alice
|
||||||
|
|
||||||
Name : bob
|
Name : bob
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Bob
|
User : Bob
|
||||||
SSH Key : {context.fixtures}/ssh-keys/bob
|
Private SSH key path : {context.fixtures}/ssh-keys/bob
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -45,17 +45,17 @@ Scenario: Add a credentials login entry
|
|||||||
Name : admin
|
Name : admin
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Admin
|
User : Admin
|
||||||
SSH Key : {context.fixtures}/ssh-keys/admin
|
Private SSH key path : {context.fixtures}/ssh-keys/admin
|
||||||
|
|
||||||
Name : alice
|
Name : alice
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Alice
|
User : Alice
|
||||||
SSH Key : {context.fixtures}/ssh-keys/alice
|
Private SSH key path : {context.fixtures}/ssh-keys/alice
|
||||||
|
|
||||||
Name : bob
|
Name : bob
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Bob
|
User : Bob
|
||||||
SSH Key : {context.fixtures}/ssh-keys/bob
|
Private SSH key path : {context.fixtures}/ssh-keys/bob
|
||||||
|
|
||||||
Name : example1
|
Name : example1
|
||||||
Default : true
|
Default : true
|
||||||
@@ -79,7 +79,7 @@ Scenario: Remove a credentials login entry
|
|||||||
Default : true
|
Default : true
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Admin
|
User : Admin
|
||||||
SSH Key : {context.fixtures}/ssh-keys/admin
|
Private SSH key path : {context.fixtures}/ssh-keys/admin
|
||||||
"""
|
"""
|
||||||
When I execute git-obs with args "login list"
|
When I execute git-obs with args "login list"
|
||||||
Then stdout is
|
Then stdout is
|
||||||
@@ -87,12 +87,12 @@ Scenario: Remove a credentials login entry
|
|||||||
Name : alice
|
Name : alice
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Alice
|
User : Alice
|
||||||
SSH Key : {context.fixtures}/ssh-keys/alice
|
Private SSH key path : {context.fixtures}/ssh-keys/alice
|
||||||
|
|
||||||
Name : bob
|
Name : bob
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Bob
|
User : Bob
|
||||||
SSH Key : {context.fixtures}/ssh-keys/bob
|
Private SSH key path : {context.fixtures}/ssh-keys/bob
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ Scenario: Update a credentials login entry
|
|||||||
Name : alice
|
Name : alice
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Alice
|
User : Alice
|
||||||
SSH Key : {context.fixtures}/ssh-keys/alice
|
Private SSH key path : {context.fixtures}/ssh-keys/alice
|
||||||
|
|
||||||
Updated entry:
|
Updated entry:
|
||||||
Name : NEW_NAME
|
Name : NEW_NAME
|
||||||
@@ -124,7 +124,7 @@ Scenario: Update a credentials login entry
|
|||||||
Name : admin
|
Name : admin
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Admin
|
User : Admin
|
||||||
SSH Key : {context.fixtures}/ssh-keys/admin
|
Private SSH key path : {context.fixtures}/ssh-keys/admin
|
||||||
|
|
||||||
Name : NEW_NAME
|
Name : NEW_NAME
|
||||||
Default : true
|
Default : true
|
||||||
@@ -134,5 +134,5 @@ Scenario: Update a credentials login entry
|
|||||||
Name : bob
|
Name : bob
|
||||||
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
URL : http://localhost:{context.podman.container.ports[gitea_http]}
|
||||||
User : Bob
|
User : Bob
|
||||||
SSH Key : {context.fixtures}/ssh-keys/bob
|
Private SSH key path : {context.fixtures}/ssh-keys/bob
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ class LoginAddCommand(osc.commandline_git.GitObsCommand):
|
|||||||
def init_arguments(self):
|
def init_arguments(self):
|
||||||
from osc.commandline_git import complete_ssh_key_path
|
from osc.commandline_git import complete_ssh_key_path
|
||||||
|
|
||||||
self.parser.add_argument("name")
|
self.parser.add_argument("name", help="The name of the login entry to be added")
|
||||||
self.parser.add_argument("--url", required=True)
|
self.parser.add_argument("--url", help="Gitea URL, for example https://example.com", required=True)
|
||||||
self.parser.add_argument("--user", required=True)
|
self.parser.add_argument("--user", help="Gitea username", required=True)
|
||||||
self.parser.add_argument("--token", help="Omit or set to '-' to invoke a secure interactive prompt.")
|
self.parser.add_argument("--token", help="Gitea access token; omit or set to '-' to invoke a secure interactive prompt")
|
||||||
self.parser.add_argument("--ssh-key").completer = complete_ssh_key_path
|
self.parser.add_argument("--ssh-key", metavar="PATH", help="Path to a private SSH key").completer = complete_ssh_key_path
|
||||||
self.parser.add_argument("--set-as-default", action="store_true", default=None)
|
self.parser.add_argument("--set-as-default", help="Set the new login entry as default", action="store_true", default=None)
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
from osc import gitea_api
|
from osc import gitea_api
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class LoginRemoveCommand(osc.commandline_git.GitObsCommand):
|
|||||||
def init_arguments(self):
|
def init_arguments(self):
|
||||||
from osc.commandline_git import complete_login
|
from osc.commandline_git import complete_login
|
||||||
|
|
||||||
self.parser.add_argument("name").completer = complete_login
|
self.parser.add_argument("name", help="The name of the login entry to be removed").completer = complete_login
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
print(f"Removing a Gitea credentials entry with name '{args.name}' ...", file=sys.stderr)
|
print(f"Removing a Gitea credentials entry with name '{args.name}' ...", file=sys.stderr)
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ class LoginUpdateCommand(osc.commandline_git.GitObsCommand):
|
|||||||
def init_arguments(self):
|
def init_arguments(self):
|
||||||
from osc.commandline_git import complete_ssh_key_path
|
from osc.commandline_git import complete_ssh_key_path
|
||||||
|
|
||||||
self.parser.add_argument("name")
|
self.parser.add_argument("name", help="The name of the login entry to be updated")
|
||||||
self.parser.add_argument("--new-name")
|
self.parser.add_argument("--new-name", help="New name of the login entry")
|
||||||
self.parser.add_argument("--new-url")
|
self.parser.add_argument("--new-url", metavar="URL", help="New Gitea URL, for example https://example.com",)
|
||||||
self.parser.add_argument("--new-user")
|
self.parser.add_argument("--new-user", metavar="USER", help="Gitea username")
|
||||||
self.parser.add_argument("--new-token", help="Set to '-' to invoke a secure interactive prompt.")
|
self.parser.add_argument("--new-token", metavar="TOKEN", help="Gitea access token; set to '-' to invoke a secure interactive prompt")
|
||||||
self.parser.add_argument("--new-ssh-key").completer = complete_ssh_key_path
|
self.parser.add_argument("--new-ssh-key", metavar="PATH", help="Path to a private SSH key").completer = complete_ssh_key_path
|
||||||
self.parser.add_argument("--set-as-default", action="store_true")
|
self.parser.add_argument("--set-as-default", action="store_true", help="Set the login entry as default")
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
print(f"Updating a Gitea credentials entry with name '{args.name}' ...", file=sys.stderr)
|
print(f"Updating a Gitea credentials entry with name '{args.name}' ...", file=sys.stderr)
|
||||||
|
|||||||
@@ -53,14 +53,14 @@ class Login(BaseModel):
|
|||||||
def to_human_readable_string(self, *, show_token: bool = False):
|
def to_human_readable_string(self, *, show_token: bool = False):
|
||||||
from osc.output import KeyValueTable
|
from osc.output import KeyValueTable
|
||||||
|
|
||||||
table = KeyValueTable()
|
table = KeyValueTable(min_key_length=20)
|
||||||
table.add("Name", self.name, color="bold")
|
table.add("Name", self.name, color="bold")
|
||||||
if self.default:
|
if self.default:
|
||||||
table.add("Default", "true", color="bold")
|
table.add("Default", "true", color="bold")
|
||||||
table.add("URL", self.url)
|
table.add("URL", self.url)
|
||||||
table.add("User", self.user)
|
table.add("User", self.user)
|
||||||
if self.ssh_key:
|
if self.ssh_key:
|
||||||
table.add("SSH Key", self.ssh_key)
|
table.add("Private SSH key path", self.ssh_key)
|
||||||
if show_token:
|
if show_token:
|
||||||
# tokens are stored in the plain text, there's not reason to protect them too much
|
# tokens are stored in the plain text, there's not reason to protect them too much
|
||||||
# let's only hide them from the output by default
|
# let's only hide them from the output by default
|
||||||
|
|||||||
Reference in New Issue
Block a user