diff --git a/osc/commands/person.py b/osc/commands/person.py new file mode 100644 index 00000000..b4e560c4 --- /dev/null +++ b/osc/commands/person.py @@ -0,0 +1,12 @@ +import osc.commandline + + +class PersonCommand(osc.commandline.OscCommand): + """ + Manage persons + """ + + name = "person" + + def run(self, args): + pass diff --git a/osc/commands/person_register.py b/osc/commands/person_register.py new file mode 100644 index 00000000..21ff0a1d --- /dev/null +++ b/osc/commands/person_register.py @@ -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, + )