mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-14 14:27:16 +01:00
Add 'person register' command
This commit is contained in:
parent
145da4e438
commit
ab749fcaf5
12
osc/commands/person.py
Normal file
12
osc/commands/person.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import osc.commandline
|
||||||
|
|
||||||
|
|
||||||
|
class PersonCommand(osc.commandline.OscCommand):
|
||||||
|
"""
|
||||||
|
Manage persons
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = "person"
|
||||||
|
|
||||||
|
def run(self, args):
|
||||||
|
pass
|
58
osc/commands/person_register.py
Normal file
58
osc/commands/person_register.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import osc.commandline
|
||||||
|
|
||||||
|
|
||||||
|
class PersonRegisterCommand(osc.commandline.OscCommand):
|
||||||
|
"""
|
||||||
|
Register a new person (user)
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = "register"
|
||||||
|
parent = "PersonCommand"
|
||||||
|
|
||||||
|
def init_arguments(self):
|
||||||
|
self.add_argument(
|
||||||
|
"--login",
|
||||||
|
required=True,
|
||||||
|
help="Login.",
|
||||||
|
)
|
||||||
|
self.add_argument(
|
||||||
|
"--realname",
|
||||||
|
required=True,
|
||||||
|
help="Real name of the person.",
|
||||||
|
)
|
||||||
|
self.add_argument(
|
||||||
|
"--email",
|
||||||
|
required=True,
|
||||||
|
help="Email address.",
|
||||||
|
)
|
||||||
|
self.add_argument(
|
||||||
|
"--password",
|
||||||
|
help="Password. An interactive prompt is shown if password is not specified.",
|
||||||
|
)
|
||||||
|
self.add_argument(
|
||||||
|
"--note",
|
||||||
|
help="Any notes about the person.",
|
||||||
|
)
|
||||||
|
self.add_argument(
|
||||||
|
"--state",
|
||||||
|
help="State of the account. Defaults to 'unconfirmed'.",
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self, args):
|
||||||
|
from osc import obs_api
|
||||||
|
from osc.util.helper import raw_input
|
||||||
|
|
||||||
|
if args.password:
|
||||||
|
password = args.password
|
||||||
|
else:
|
||||||
|
password = raw_input(f"Enter password for {args.login}@{args.apiurl}: ")
|
||||||
|
|
||||||
|
obs_api.Person.cmd_register(
|
||||||
|
args.apiurl,
|
||||||
|
login=args.login,
|
||||||
|
realname=args.realname,
|
||||||
|
email=args.email,
|
||||||
|
password=password,
|
||||||
|
note=args.note,
|
||||||
|
state=args.state,
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user