diff --git a/ask/ask.go b/ask/ask.go index bdde8a350a9d05ac26cd84870cee0c13fe156890..e58a68c9a7fb7becff422273f7b19e3481ce66f3 100644 --- a/ask/ask.go +++ b/ask/ask.go @@ -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" +} diff --git a/repl/command.go b/repl/command.go index 4f498338120a2b68d23b2f4674325ca8dbf17bab..79ec62eb640e5084df58972a9481a9d653b3b050 100644 --- a/repl/command.go +++ b/repl/command.go @@ -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, diff --git a/repl/show.go b/repl/show.go index a2d628dfee08fa3ac9d8fcdca70dadc960206969..80481f862242842865726aab7bb372622b9d7c6d 100644 --- a/repl/show.go +++ b/repl/show.go @@ -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 }