packages feed

proto-lens-optparse (empty) → 0.1.0.0

raw patch · 4 files changed

+98/−0 lines, 4 filesdep +basedep +optparse-applicativedep +proto-lenssetup-changed

Dependencies added: base, optparse-applicative, proto-lens, text

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2016, Google Inc.++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Google Inc. nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ proto-lens-optparse.cabal view
@@ -0,0 +1,25 @@+name:                proto-lens-optparse+version:             0.1.0.0+synopsis:            Adapting proto-lens to optparse-applicative ReadMs.+description:+   A package adapting proto-lens to optparse-applicative ReadMs.+   This gives an easy way to define options and arguments for+   text-format protobuf types.++homepage:            https://github.com/google/proto-lens+license:             BSD3+license-file:        LICENSE+author:              Andrew Pritchard+maintainer:          awpr+protolens@google.com+copyright:           Google Inc.+category:            Data+build-type:          Simple+cabal-version:       >=1.8++library+  hs-source-dirs: src+  exposed-modules:     Data.ProtoLens.Optparse+  build-depends:  proto-lens == 0.1.*+                , base == 4.8.*+                , optparse-applicative == 0.12.*+                , text == 1.2.*
+ src/Data/ProtoLens/Optparse.hs view
@@ -0,0 +1,41 @@+-- Copyright 2016 Google Inc. All Rights Reserved.+--+-- Use of this source code is governed by a BSD-style+-- license that can be found in the LICENSE file or at+-- https://developers.google.com/open-source/licenses/bsd++-- | Adapting proto-lens to optparse-applicative ReadMs.+-- This gives an easy way to define options and arguments for+-- text-format protobuf types.+module Data.ProtoLens.Optparse+    ( proto+    , protoOption+    , protoArgument+    ) where++import Data.ProtoLens.Message (Message)+import Data.ProtoLens.TextFormat (readMessage)+import qualified Data.Text.Lazy as TL+import Options.Applicative+  ( ArgumentFields+  , Mod+  , ReadM+  , OptionFields+  , Parser+  , argument+  , eitherReader+  , option+  )++-- | An optparse-applicative 'ReadM' for a text-format protobuf.  This lets you+-- have flags or arguments with protobuf values.+proto :: Message a => ReadM a+proto = eitherReader (readMessage . TL.pack)++-- | Shorthand for a text-format protobuf option.+protoOption :: Message a => Mod OptionFields a -> Parser a+protoOption = option proto++-- | Shorthand for a text-format protobuf argument.+protoArgument :: Message a => Mod ArgumentFields a -> Parser a+protoArgument = argument proto