From 785fa3295c0fb68e113be4620523d8812b6a9def Mon Sep 17 00:00:00 2001 From: Shuo Date: Wed, 17 Mar 2021 15:50:02 +0800 Subject: [PATCH] Add StringCmd.Bool() --- command.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/command.go b/command.go index b45a3edc9..f10c4781a 100644 --- a/command.go +++ b/command.go @@ -710,6 +710,13 @@ func (cmd *StringCmd) Bytes() ([]byte, error) { return util.StringToBytes(cmd.val), cmd.err } +func (cmd *StringCmd) Bool() (bool, error) { + if cmd.err != nil { + return false, cmd.err + } + return strconv.ParseBool(cmd.val) +} + func (cmd *StringCmd) Int() (int, error) { if cmd.err != nil { return 0, cmd.err