Unverified Commit 561977c3 authored by Kevin Lyda's avatar Kevin Lyda
Browse files

More on SHOW USER

Add another arg parser - ParseDate.  Flesh out the /SINCE
flag.
parent fef67c76
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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)
}
+1 −8
Original line number Diff line number Diff line
@@ -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": {
+12 −3
Original line number Diff line number Diff line
@@ -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
}