@@ -59,21 +59,42 @@ protected function configure(): void {
5959 ;
6060 }
6161
62- protected function execute (InputInterface $ input , OutputInterface $ output ): int {
62+ protected function execute (InputInterface $ input , OutputInterface $ output ): int {
6363 $ singleUserId = $ input ->getArgument ('uid ' );
6464 if ($ singleUserId ) {
6565 $ user = $ this ->userManager ->get ($ singleUserId );
6666 if (is_null ($ user )) {
6767 $ output ->writeln ('<error>User does not exist</error> ' );
6868 return 1 ;
6969 }
70- $ users = [$ user ];
71- } elseif ($ input ->getOption ('all ' )) {
72- $ users = $ this ->userManager ->search ('' );
73- } else {
70+
71+ $ lastLogin = $ user ->getLastLogin ();
72+ if ($ lastLogin === 0 ) {
73+ $ output ->writeln ($ user ->getUID () . ' has never logged in. ' );
74+ } else {
75+ $ date = new \DateTime ();
76+ $ date ->setTimestamp ($ lastLogin );
77+ $ output ->writeln ($ user ->getUID () . "'s last login: " . $ date ->format ('Y-m-d H:i ' ));
78+ }
79+
80+ return 0 ;
81+ }
82+
83+ if (!$ input ->getOption ('all ' )) {
7484 $ output ->writeln ("<error>Please specify a username, or \"--all \" to list all</error> " );
7585 return 1 ;
7686 }
87+
88+ $ this ->userManager ->callForAllUsers (static function (IUser $ user ) use ($ output ) {
89+ $ lastLogin = $ user ->getLastLogin ();
90+ if ($ lastLogin === 0 ) {
91+ $ output ->writeln ($ user ->getUID () . ' has never logged in. ' );
92+ } else {
93+ $ date = new \DateTime ();
94+ $ date ->setTimestamp ($ lastLogin );
95+ $ output ->writeln ($ user ->getUID () . "'s last login: " . $ date ->format ('Y-m-d H:i ' ));
96+ }
97+ });
7798 return 0 ;
7899 }
79100
0 commit comments