Skip to content

Scan commands #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions codegen/GenCmds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ groupCmds (Cmds cmds) =
, "connection"
, "server"
, "scripting"
-- not implemented:
-- , "cluster"
-- , "geo"
]

-- |Blacklisted commands, optionally paired with the name of their
Expand Down Expand Up @@ -78,6 +81,41 @@ blacklist = [ manual "AUTH" ["auth"]
["zrevrangebyscore", "zrevrangebyscoreWithscores"
,"zrevrangebyscoreLimit", "zrevrangebyscoreWithscoresLimit"]
, manual "ZUNIONSTORE" ["zunionstore","zunionstoreWeights"]
, manualWithType "SET"
["set", "setOpts"]
["Condition", "SetOpts(..)"]
, manualWithType "ZADD"
["zadd", "zaddOpts"]
["ZaddOpts(..)", "defaultZaddOpts"]
, manualWithType "MIGRATE"
["migrate", "migrateMultiple"]
["MigrateOpts(..)", "defaultMigrateOpts"]
, manual "RESTORE"
["restore", "restoreReplace"]
, manualWithType "CLIENT REPLY"
["clientReply"]
["ReplyMode"]
, manualWithType "SCRIPT DEBUG"
["scriptDebug"]
["DebugMode"]
, manual "SRANDMEMBER" ["srandmember", "srandmemberN"]
, manual "SPOP" ["spop"]
, manual "INFO" ["info", "infoSection"]
, manual "EXISTS" ["exists"]
, manualWithType "SCAN"
["scan", "scanOpts"]
["Cursor", "cursor0", "ScanOpts(..)", "defaultScanOpts"]
, manual "SSCAN" ["sscan", "sscanOpts"]
, manual "HSCAN" ["hscan", "hscanOpts"]
, manual "ZSCAN" ["zscan", "zscanOpts"]
, unimplemented "COMMAND"
, unimplemented "COMMAND GETKEYS"
, unimplemented "ROLE"
, unimplemented "CLIENT KILL"
, unimplemented "ZRANGEBYLEX"
, unimplemented "ZREVRANGEBYLEX"
, unimplemented "ZRANGEBYSCORE"
, unimplemented "ZREVRANGEBYSCORE"
, unimplemented "MONITOR" -- debugging command
, unimplemented "SYNC" -- internal command
, unimplemented "SHUTDOWN" -- kills server, throws exception
Expand All @@ -101,7 +139,7 @@ data Cmd = Cmd { cmdName, cmdGroup :: String
, cmdRetType :: Maybe String
, cmdArgs :: [Arg]
, cmdSummary :: String
, cmdSince :: String
, cmdSince :: Maybe String
}
deriving (Show)

Expand All @@ -124,7 +162,7 @@ instance FromJSON Cmds where
cmdGroup <- cmd .: "group"
cmdRetType <- cmd .:? "returns"
cmdSummary <- cmd .: "summary"
cmdSince <- cmd .: "since"
cmdSince <- cmd .:? "since"
cmdArgs <- cmd .:? "arguments" .!= []
<|> error ("failed to parse args: " ++ cmdName)
return Cmd{..})
Expand Down Expand Up @@ -273,7 +311,9 @@ exportCmdNames Cmd{..} = types `mappend` functions
, fromString "'."
]
else mempty
, fromString " Since Redis ", fromString cmdSince
, case cmdSince of
Just ver -> mconcat [fromString " Since Redis ", fromString ver]
Nothing -> fromString " In unstable version of Redis"
]

cmdDescriptionLink :: String -> Builder
Expand Down Expand Up @@ -381,6 +421,7 @@ argumentType a = mconcat [ go a
go (Pair a a') =
mconcat [fromString "(", go a, fromString ",", go a', fromString ")"]
go a@Arg{..} = translateArgType a
go a = error ("failed to user argument type: " ++ show a)

translateArgType Arg{..} = fromString $ case argType of
"integer" -> "Integer"
Expand Down
Loading