mirror of
https://github.com/swarm-game/swarm.git
synced 2025-01-05 23:34:35 +03:00
parent
bd552e3615
commit
c6288e53cb
@ -49,17 +49,16 @@ cliParser =
|
||||
<> help ("Set the address of " <> replace "-" " " n <> ". Default no link.")
|
||||
)
|
||||
in PageAddress <$> opt "entities-page" <*> opt "commands-page" <*> opt "capabilities-page" <*> opt "recipes-page"
|
||||
cheatsheet :: Parser (Maybe SheetType)
|
||||
cheatsheet :: Parser SheetType
|
||||
cheatsheet =
|
||||
Data.Foldable.asum
|
||||
[ pure Nothing
|
||||
, Just Entities <$ switch (long "entities" <> help "Generate entities page (uses data from entities.yaml)")
|
||||
, Just Terrain <$ switch (long "terrain" <> help "Generate terrain page (uses data from terrains.yaml)")
|
||||
, Just Recipes <$ switch (long "recipes" <> help "Generate recipes page (uses data from recipes.yaml)")
|
||||
, Just Capabilities <$ switch (long "capabilities" <> help "Generate capabilities page (uses entity map)")
|
||||
, Just Commands <$ switch (long "commands" <> help "Generate commands page (uses constInfo, constCaps and inferConst)")
|
||||
, Just CommandMatrix <$ switch (long "matrix" <> help "Generate commands matrix page")
|
||||
, Just Scenario <$ switch (long "scenario" <> help "Generate scenario schema page")
|
||||
[ flag' Entities (long "entities" <> help "Generate entities page (uses data from entities.yaml)")
|
||||
, flag' Terrain (long "terrain" <> help "Generate terrain page (uses data from terrains.yaml)")
|
||||
, flag' Recipes (long "recipes" <> help "Generate recipes page (uses data from recipes.yaml)")
|
||||
, flag' Capabilities (long "capabilities" <> help "Generate capabilities page (uses entity map)")
|
||||
, flag' Commands (long "commands" <> help "Generate commands page (uses constInfo, constCaps and inferConst)")
|
||||
, flag' CommandMatrix (long "matrix" <> help "Generate commands matrix page")
|
||||
, flag' Scenario (long "scenario" <> help "Generate scenario schema page")
|
||||
]
|
||||
|
||||
cliInfo :: ParserInfo GenerateDocs
|
||||
|
@ -72,7 +72,7 @@ data GenerateDocs where
|
||||
-- | List of special key names recognized by 'Swarm.Language.Syntax.Key' command
|
||||
SpecialKeyNames :: GenerateDocs
|
||||
-- | Cheat sheets for inclusion on the Swarm wiki.
|
||||
CheatSheet :: PageAddress -> Maybe SheetType -> GenerateDocs
|
||||
CheatSheet :: PageAddress -> SheetType -> GenerateDocs
|
||||
-- | List command introductions by tutorial
|
||||
TutorialCoverage :: GenerateDocs
|
||||
deriving (Eq, Show)
|
||||
|
@ -62,28 +62,26 @@ data SheetType = Entities | Terrain | Commands | CommandMatrix | Capabilities |
|
||||
|
||||
-- * Functions
|
||||
|
||||
makeWikiPage :: PageAddress -> Maybe SheetType -> IO ()
|
||||
makeWikiPage :: PageAddress -> SheetType -> IO ()
|
||||
makeWikiPage address s = case s of
|
||||
Nothing -> error "Not implemented for all Wikis"
|
||||
Just st -> case st of
|
||||
Commands -> T.putStrLn commandsPage
|
||||
CommandMatrix -> case pandocToText commandsMatrix of
|
||||
Right x -> T.putStrLn x
|
||||
Left x -> error $ T.unpack x
|
||||
Capabilities -> simpleErrorHandle $ do
|
||||
entities <- loadEntities
|
||||
sendIO $ T.putStrLn $ capabilityPage address entities
|
||||
Entities -> simpleErrorHandle $ do
|
||||
entities <- loadEntities
|
||||
sendIO $ T.putStrLn $ entitiesPage address (Map.elems $ entitiesByName entities)
|
||||
Terrain -> simpleErrorHandle $ do
|
||||
terrains <- loadTerrain
|
||||
sendIO . T.putStrLn . T.unlines . map showT . Map.elems $ terrainByName terrains
|
||||
Recipes -> simpleErrorHandle $ do
|
||||
entities <- loadEntities
|
||||
recipes <- loadRecipes entities
|
||||
sendIO $ T.putStrLn $ recipePage address recipes
|
||||
Scenario -> genScenarioSchemaDocs
|
||||
Commands -> T.putStrLn commandsPage
|
||||
CommandMatrix -> case pandocToText commandsMatrix of
|
||||
Right x -> T.putStrLn x
|
||||
Left x -> error $ T.unpack x
|
||||
Capabilities -> simpleErrorHandle $ do
|
||||
entities <- loadEntities
|
||||
sendIO $ T.putStrLn $ capabilityPage address entities
|
||||
Entities -> simpleErrorHandle $ do
|
||||
entities <- loadEntities
|
||||
sendIO $ T.putStrLn $ entitiesPage address (Map.elems $ entitiesByName entities)
|
||||
Terrain -> simpleErrorHandle $ do
|
||||
terrains <- loadTerrain
|
||||
sendIO . T.putStrLn . T.unlines . map showT . Map.elems $ terrainByName terrains
|
||||
Recipes -> simpleErrorHandle $ do
|
||||
entities <- loadEntities
|
||||
recipes <- loadRecipes entities
|
||||
sendIO $ T.putStrLn $ recipePage address recipes
|
||||
Scenario -> genScenarioSchemaDocs
|
||||
|
||||
-- ----------------------------------------------------------------------------
|
||||
-- GENERATE TABLES: COMMANDS, ENTITIES AND CAPABILITIES TO MARKDOWN TABLE
|
||||
|
Loading…
Reference in New Issue
Block a user