Skip to content

Commit

Permalink
Add 'person register' command
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed May 21, 2024
1 parent 145da4e commit ab749fc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
12 changes: 12 additions & 0 deletions osc/commands/person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import osc.commandline


class PersonCommand(osc.commandline.OscCommand):
"""
Manage persons
"""

name = "person"

def run(self, args):
pass
58 changes: 58 additions & 0 deletions osc/commands/person_register.py
Original file line number Diff line number Diff line change
@@ -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,
)

0 comments on commit ab749fc

Please sign in to comment.