Fix the cheat sheet options (#2047)

Closes #2045.
This commit is contained in:
Noah Yorgey 2024-07-15 10:55:32 -04:00 committed by GitHub
parent bd552e3615
commit c6288e53cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 31 deletions

View File

@ -49,17 +49,16 @@ cliParser =
<> help ("Set the address of " <> replace "-" " " n <> ". Default no link.") <> help ("Set the address of " <> replace "-" " " n <> ". Default no link.")
) )
in PageAddress <$> opt "entities-page" <*> opt "commands-page" <*> opt "capabilities-page" <*> opt "recipes-page" in PageAddress <$> opt "entities-page" <*> opt "commands-page" <*> opt "capabilities-page" <*> opt "recipes-page"
cheatsheet :: Parser (Maybe SheetType) cheatsheet :: Parser SheetType
cheatsheet = cheatsheet =
Data.Foldable.asum Data.Foldable.asum
[ pure Nothing [ flag' Entities (long "entities" <> help "Generate entities page (uses data from entities.yaml)")
, Just Entities <$ switch (long "entities" <> help "Generate entities page (uses data from entities.yaml)") , flag' Terrain (long "terrain" <> help "Generate terrain page (uses data from terrains.yaml)")
, Just Terrain <$ switch (long "terrain" <> help "Generate terrain page (uses data from terrains.yaml)") , flag' Recipes (long "recipes" <> help "Generate recipes page (uses data from recipes.yaml)")
, Just Recipes <$ switch (long "recipes" <> help "Generate recipes page (uses data from recipes.yaml)") , flag' Capabilities (long "capabilities" <> help "Generate capabilities page (uses entity map)")
, Just Capabilities <$ switch (long "capabilities" <> help "Generate capabilities page (uses entity map)") , flag' Commands (long "commands" <> help "Generate commands page (uses constInfo, constCaps and inferConst)")
, Just Commands <$ switch (long "commands" <> help "Generate commands page (uses constInfo, constCaps and inferConst)") , flag' CommandMatrix (long "matrix" <> help "Generate commands matrix page")
, Just CommandMatrix <$ switch (long "matrix" <> help "Generate commands matrix page") , flag' Scenario (long "scenario" <> help "Generate scenario schema page")
, Just Scenario <$ switch (long "scenario" <> help "Generate scenario schema page")
] ]
cliInfo :: ParserInfo GenerateDocs cliInfo :: ParserInfo GenerateDocs

View File

@ -72,7 +72,7 @@ data GenerateDocs where
-- | List of special key names recognized by 'Swarm.Language.Syntax.Key' command -- | List of special key names recognized by 'Swarm.Language.Syntax.Key' command
SpecialKeyNames :: GenerateDocs SpecialKeyNames :: GenerateDocs
-- | Cheat sheets for inclusion on the Swarm wiki. -- | Cheat sheets for inclusion on the Swarm wiki.
CheatSheet :: PageAddress -> Maybe SheetType -> GenerateDocs CheatSheet :: PageAddress -> SheetType -> GenerateDocs
-- | List command introductions by tutorial -- | List command introductions by tutorial
TutorialCoverage :: GenerateDocs TutorialCoverage :: GenerateDocs
deriving (Eq, Show) deriving (Eq, Show)

View File

@ -62,10 +62,8 @@ data SheetType = Entities | Terrain | Commands | CommandMatrix | Capabilities |
-- * Functions -- * Functions
makeWikiPage :: PageAddress -> Maybe SheetType -> IO () makeWikiPage :: PageAddress -> SheetType -> IO ()
makeWikiPage address s = case s of makeWikiPage address s = case s of
Nothing -> error "Not implemented for all Wikis"
Just st -> case st of
Commands -> T.putStrLn commandsPage Commands -> T.putStrLn commandsPage
CommandMatrix -> case pandocToText commandsMatrix of CommandMatrix -> case pandocToText commandsMatrix of
Right x -> T.putStrLn x Right x -> T.putStrLn x