From 561977c3c4a49d99ce7e6369d0de75af25320211 Mon Sep 17 00:00:00 2001
From: Kevin Lyda <kevin@lyda.ie>
Date: Fri, 16 May 2025 08:59:12 +0100
Subject: [PATCH] More on SHOW USER

Add another arg parser - ParseDate.  Flesh out the /SINCE
flag.
---
 repl/args.go    |  6 ++++++
 repl/command.go |  9 +--------
 repl/show.go    | 15 ++++++++++++---
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/repl/args.go b/repl/args.go
index dd88455..e993155 100644
--- a/repl/args.go
+++ b/repl/args.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"strconv"
 	"strings"
+	"time"
 )
 
 // ParseNumberList takes a string with a number list
@@ -41,3 +42,8 @@ func ParseNumberList(input string) ([]int64, error) {
 	}
 	return result, nil
 }
+
+// ParseDate converts a "yyyy-mm-dd" formatted string to time.Time.
+func ParseDate(arg string) (time.Time, error) {
+	return time.Parse("2006-01-02", arg)
+}
diff --git a/repl/command.go b/repl/command.go
index 074fdcf..1552160 100644
--- a/repl/command.go
+++ b/repl/command.go
@@ -1630,6 +1630,7 @@ sites  make  BULLETIN/LOGIN  an  optional  command for users to store in
 their own LOGIN.COM, so this command can be used  to  show  which  users
 have done this.`,
 				MaxArgs: 1,
+				Action:  ActionShowUser,
 				Flags: dclish.Flags{
 					"/ALL": {
 						Description: `  Specifies that information for all users is to be displayed. This is a
@@ -1658,14 +1659,6 @@ have done this.`,
   specified, the  date of the  current message  is used. Only  valid for
   folders or with /LOGIN. Use /START for newsgroups.`,
 					},
-					"/START": {
-						Description: `/START=[number]
-
-  Specifies to display only those users whose latest read message number
-  is equal  to or greather  than the specified  number. If no  number is
-  specified, the  message number  of the current  message is  used. Only
-  valid for newsgroups. Use /SINCE for folders and with /LOGIN.`,
-					},
 				},
 			},
 			"VERSION": {
diff --git a/repl/show.go b/repl/show.go
index f800729..3f4a05e 100644
--- a/repl/show.go
+++ b/repl/show.go
@@ -118,8 +118,10 @@ func ActionShowPrivileges(_ *dclish.Command) error {
 func ActionShowUser(cmd *dclish.Command) error {
 	showAll := false
 	if cmd.Flags["/ALL"].Value == "true" {
-		// TODO: Check permissions.
 		showAll = true
+		// TODO: Check permissions.
+		fmt.Println("ERROR: No privs to use command.")
+		return nil
 	}
 	showLogin := false
 	if cmd.Flags["/LOGIN"].Value == "true" {
@@ -131,9 +133,16 @@ func ActionShowUser(cmd *dclish.Command) error {
 		// TODO: Check permissions.
 		folder = folders.FindFolder(cmd.Flags["/FOLDER"].Value)
 	}
-	since := cmd.Flags["/FOLDER"].Value
+	if cmd.Flags["/FOLDER"].Value != "" {
+		since, err := ParseDate(cmd.Flags["/FOLDER"].Value)
+		if err != nil {
+			fmt.Println("ERROR: Invalid date specified.")
+			return nil
+		}
+		fmt.Printf("TODO: select messages since %s.\n", since.Format("2006-05-04"))
+	}
 	fmt.Println("TODO: implement ActionShowUser.")
-	fmt.Printf("TODO: %t %t %s %s.\n", showAll, showLogin, folder.Name, since)
+	fmt.Printf("TODO: %t %t %s.\n", showAll, showLogin, folder.Name)
 	return nil
 }
 
-- 
GitLab