Skip to content

Commit

Permalink
allow shortened versions of colon commands
Browse files Browse the repository at this point in the history
resolves #271
  • Loading branch information
agentm committed Nov 7, 2020
1 parent a45300a commit d1e6eee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/bin/TutorialD/Interpreter/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ utcTimeP = do
Just stamp' -> pure stamp'


colonOp :: Text -> Parser ()
colonOp opStr = do
_ <- string opStr <* spaceChar <* spaceConsumer
colonOp :: Text -> Text -> Parser ()
colonOp opStr shortOpStr = do
_ <- (string opStr <|> string shortOpStr) <* spaceChar <* spaceConsumer
pure ()
22 changes: 11 additions & 11 deletions src/bin/TutorialD/Interpreter/RODatabaseContextOperator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,44 @@ data RODatabaseContextOperator where

typeP :: Parser RODatabaseContextOperator
typeP = do
colonOp ":type"
colonOp ":type" ":t"
ShowRelationType <$> relExprP

showRelP :: Parser RODatabaseContextOperator
showRelP = do
colonOp ":showexpr"
colonOp ":showexpr" ":se"
ShowRelation <$> relExprP

showPlanP :: Parser RODatabaseContextOperator
showPlanP = do
colonOp ":showplan"
colonOp ":showplan" ":sp"
ShowPlan <$> databaseContextExprP

showTypesP :: Parser RODatabaseContextOperator
showTypesP = colonOp ":showtypes" >> pure ShowTypes
showTypesP = colonOp ":showtypes" ":st" >> pure ShowTypes

showRelationVariables :: Parser RODatabaseContextOperator
showRelationVariables = colonOp ":showrelvars" >> pure ShowRelationVariables
showRelationVariables = colonOp ":showrelvars" ":srv" >> pure ShowRelationVariables

showAtomFunctionsP :: Parser RODatabaseContextOperator
showAtomFunctionsP = colonOp ":showatomfunctions" >> pure ShowAtomFunctions
showAtomFunctionsP = colonOp ":showatomfunctions" ":saf" >> pure ShowAtomFunctions

showDatabaseContextFunctionsP :: Parser RODatabaseContextOperator
showDatabaseContextFunctionsP = colonOp ":showdatabasecontextfunctions" >> pure ShowDatabaseContextFunctions
showDatabaseContextFunctionsP = colonOp ":showdatabasecontextfunctions" ":sdbf" >> pure ShowDatabaseContextFunctions

quitP :: Parser RODatabaseContextOperator
quitP = do
colonOp ":quit"
colonOp ":quit" ":q"
return Quit

showConstraintsP :: Parser RODatabaseContextOperator
showConstraintsP = do
colonOp ":constraints"
colonOp ":constraints" ":c"
ShowConstraint <$> option "" identifier

plotRelExprP :: Parser RODatabaseContextOperator
plotRelExprP = do
colonOp ":plotexpr"
colonOp ":plotexpr" ":pe"
PlotRelation <$> relExprP

roDatabaseContextOperatorP :: Parser RODatabaseContextOperator
Expand Down Expand Up @@ -164,7 +164,7 @@ interpretRODatabaseContextOp sessionId conn tutdstring = case parse roDatabaseCo

showDataFrameP :: Parser RODatabaseContextOperator
showDataFrameP = do
colonOp ":showdataframe"
colonOp ":showdataframe" ":sdf"
relExpr <- relExprP
reservedOp "orderby"
attrOrdersExpr <- attrOrdersExprP
Expand Down

0 comments on commit d1e6eee

Please sign in to comment.