- # Try to set the password
- try {
- $user->setPassword( $password );
- } catch ( PasswordError $pwe ) {
- $this->error( $pwe->getText(), true );
+ $exists = ( 0 !== $user->idForName() );
+
+ if ( $exists && !$force ) {
+ $this->error( "Account exists. Perhaps you want the --force option?", true );
+ } elseif ( !$exists && !$password ) {
+ $this->error( "Argument <password> required!", false );
+ $this->maybeHelp( true );
+ } elseif ( $exists ) {
+ $inGroups = $user->getGroups();