packages feed

yesod-raml-bin (empty) → 0.1.0

raw patch · 6 files changed

+156/−0 lines, 6 filesdep +basedep +blaze-htmldep +blaze-markupsetup-changed

Dependencies added: base, blaze-html, blaze-markup, bytestring, containers, optparse-applicative, shakespeare, template-haskell, text, yaml, yesod-markdown, yesod-raml, yesod-raml-docs

Files

+ ChangeLog.md view
@@ -0,0 +1,3 @@+## 0.1.0++* First Release
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 Junji Hashimoto++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ README.md view
@@ -0,0 +1,29 @@+# Yesod-Raml-Bin: ++Yesod-Raml-Bin is a utility program for yesod-raml.+The functions are below.++1, Verify RAML format+2, Convert RAML to HTML+3, Convert RAML to Yesod-Route file+++## Usage++Verify RAML file. (Curretly just use parser of Data.Yaml.)++```+> yesod-raml-bin verfiy "raml file"+```++Convert RAML to HTML.++```+> yesod-raml-bin tohtml "raml file" "html file"+```++Generate routes file for Yesod.++```+> yesod-raml-bin toroute "raml file" "routes file"+```
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ main.hs view
@@ -0,0 +1,62 @@+import Yesod.Raml.Type+import Yesod.Raml.Routes+import Yesod.Raml.Docs+import qualified Data.Yaml as Y+import qualified Data.Text.Lazy as T+import qualified Data.Text.Lazy.IO as T+import Text.Blaze.Html.Renderer.Text++import Options.Applicative++data Command =+    ToRoute FilePath FilePath+  | ToHtml FilePath FilePath+  | Verify FilePath++toroute :: Parser Command+toroute = ToRoute+         <$> (argument str (metavar "RamlFile"))+         <*> (argument str (metavar "RouteFile"))++tohtml :: Parser Command+tohtml = ToHtml+         <$> (argument str (metavar "RamlFile"))+         <*> (argument str (metavar "HtmlFile"))++parse :: Parser Command+parse = subparser $ +        command "toroute" (info toroute (progDesc "convert raml-file to route-file")) <>+        command "tohtml" (info tohtml (progDesc "convert raml-file to html-file")) <>+        command "verify" (info verify (progDesc "verify raml-file"))++verify :: Parser Command+verify = Verify <$> (argument str (metavar "RamlFile"))+++runCmd :: Command -> IO ()+runCmd (ToRoute ifile ofile) = do+  v <- Y.decodeFileEither ifile :: IO (Either Y.ParseException Raml)+  case v of+    Left e -> print (show e)+    Right raml' ->  do+      case routesFromRaml raml' of+        Left e -> print (show e)+        Right routes ->  T.writeFile ofile (T.fromStrict (toYesodRoutes routes))++runCmd (ToHtml ifile ofile) = do+  v <- Y.decodeFileEither ifile :: IO (Either Y.ParseException Raml)+  case v of+    Left e -> print (show e)+    Right raml' -> T.writeFile ofile (renderHtml (htmlFromRaml raml'))++runCmd (Verify file) = do+  v <- Y.decodeFileEither file :: IO (Either Y.ParseException Raml)+  print v+      ++opts :: ParserInfo Command+opts = info (parse <**> helper) idm+  +main :: IO ()+main = execParser opts >>= runCmd+  
+ yesod-raml-bin.cabal view
@@ -0,0 +1,40 @@+name:                yesod-raml-bin+version:             0.1.0+synopsis:            The raml helper executable.+description:         Provides html documentation and route file generator+license:             MIT+license-file:        LICENSE+author:              junji.hashimoto+maintainer:          junji.hashimoto@gmail.com+category:            Web, Yesod+build-type:          Simple+cabal-version:       >=1.10+extra-source-files:   ChangeLog.md+                    , README.md++bug-reports:         https://github.com/junjihashimoto/yesod-raml/issues++source-repository head+  type:           git+  location:       https://github.com/junjihashimoto/yesod-raml.git+++executable yesod-raml-bin+  main-is: main.hs+  -- other-modules:       +  -- other-extensions:    +  build-depends:       base ==4.*+                     , yesod-raml == 0.2.*+                     , yesod-raml-docs == 0.1.*+                     , yesod-markdown+                     , shakespeare+                     , blaze-markup+                     , blaze-html+                     , containers+                     , text+                     , optparse-applicative+                     , yaml+                     , bytestring+                     , template-haskell+  default-language:    Haskell2010+  ghc-options:       -Wall