From e9f057db55da3480342868770335bbe320ef4165 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Fri, 31 Aug 2018 11:44:36 +0200 Subject: [PATCH] embed files in the bin --- gpm.cabal | 5 ++++- package.yaml | 3 ++- src/GPM.hs | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/gpm.cabal b/gpm.cabal index 8b79436..6d73dbf 100644 --- a/gpm.cabal +++ b/gpm.cabal @@ -2,12 +2,13 @@ -- -- see: https://github.com/sol/hpack -- --- hash: a686a36064ef8ecb9b6b995eff90b19c3c02223326995cc6f0ae33c7f7d699f5 +-- hash: 33fb8dc1910b29dc2948850dc3ab52f6a6c420a93c0113d1fc81076fcd555c3a name: gpm version: 0.1.0.0 category: Test stability: alpha (experimental) +homepage: https://gitlab.esy.fun/yogsototh/gpm author: Yann Esposito maintainer: yann.esposito@gmail.com copyright: © 2017 Yann Esposito @@ -30,6 +31,7 @@ library ghc-options: -O2 -Werror -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances build-depends: base >=4.8 && <5 + , file-embed , protolude , turtle default-language: Haskell2010 @@ -44,6 +46,7 @@ executable gpm ghc-options: -O2 -Werror -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -threaded -rtsopts -with-rtsopts=-N -optP-Wno-nonportable-include-path build-depends: base >=4.8 && <5 + , file-embed , gpm , protolude , turtle diff --git a/package.yaml b/package.yaml index a4c0d9f..b658fd5 100644 --- a/package.yaml +++ b/package.yaml @@ -5,7 +5,7 @@ author: Yann Esposito maintainer: yann.esposito@gmail.com copyright: © 2017 Yann Esposito license: ISC -url: https://gitlab.esy.fun/yogsototh/gpm +homepage: https://gitlab.esy.fun/yogsototh/gpm default-extensions: - OverloadedStrings - NoImplicitPrelude @@ -26,6 +26,7 @@ dependencies: - base >=4.8 && <5 - protolude - turtle +- file-embed library: source-dirs: src executables: diff --git a/src/GPM.hs b/src/GPM.hs index c4c851e..9b78af4 100755 --- a/src/GPM.hs +++ b/src/GPM.hs @@ -1,19 +1,22 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell #-} module GPM where -import Protolude hiding (stdout,(%),die) -import Turtle +import Data.FileEmbed (embedStringFile) +import Protolude hiding (die, stdout, (%)) +import Turtle -import GPM.Review (handleReview,ReviewCommand(..),parseReviewCmd) +import GPM.Review (ReviewCommand (..), handleReview, + parseReviewCmd) gpm :: IO () gpm = do subcmd <- options "Git Project Manager" parser case subcmd of - Init -> init - NewIssue -> newIssue + Init -> init + NewIssue -> newIssue Review reviewCmd -> handleReview reviewCmd data Command = Init @@ -55,15 +58,13 @@ debug cmd = do initIssues :: IO () initIssues = do echo "* issue.org" - input ("templates" "issues.org") - & output "issues.org" + output "issues.org" $(embedStringFile "templates/issues.org") debug "git add issues.org" initDocs :: IO () initDocs = do echo "* wiki.org" - input ("templates" "wiki.org") - & output "wiki.org" + output "wiki.org" $(embedStringFile "templates/wiki.org") debug "git add wiki.org" initReview :: IO () @@ -71,6 +72,5 @@ initReview = do let fic = "reviews" "write-contributing-yogsototh.org" mktree "reviews" putText $ format ("* "%fp) fic - input ("templates" "review.org") - & output fic + output fic $(embedStringFile "templates/review.org") debug "git add reviews"