Unverified Commit 7410cef1 authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Add SHOW PRIVILEGES

parent 115800b4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -52,3 +52,11 @@ func Choose(prompt string, choices []string) (int, error) {
	}
	return choice, nil
}

// YesNo converts an int64 to "yes" (`!= 0`) or "no" (`== 0`).
func YesNo(num int64) string {
	if num != 0 {
		return "yes"
	}
	return "no"
}
+1 −0
Original line number Diff line number Diff line
@@ -1485,6 +1485,7 @@ have been set.`,
				Description: `Shows the  privileges necessary to  use privileged commands.  Also shows
any  rights identifiers  that would  also give  a user  privileges. (The
latter are ACLs which are set on the BULLUSER.DAT file.)`,
				Action: ActionShowPrivileges,
			},
			"USER": {
				Description: `Shows the last time that a user logged in, or if /FOLDER  is  specified,
+5 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import (

	"github.com/carlmjohnson/versioninfo"

	"git.lyda.ie/kevin/bulletin/ask"
	"git.lyda.ie/kevin/bulletin/dclish"
	"git.lyda.ie/kevin/bulletin/folders"
	"git.lyda.ie/kevin/bulletin/storage"
@@ -117,7 +118,10 @@ func ActionShowNew(_ *dclish.Command) error {

// ActionShowPrivileges handles the `SHOW PRIVILEGES` command.
func ActionShowPrivileges(_ *dclish.Command) error {
	fmt.Println("TODO: implement ActionShowPrivileges.")
	fmt.Printf("Account privileges for %s:\n", this.User.Login)
	fmt.Printf("  Admin     : %s\n", ask.YesNo(this.User.Admin))
	fmt.Printf("  Moderator : %s\n", ask.YesNo(this.User.Moderator))
	fmt.Printf("  Alert     : %s\n", ask.YesNo(this.User.Alert))
	return nil
}