From 2dbfb4bbd7ca6d21181c567b355f2e36b5fe6cc6 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Fri, 31 Aug 2018 11:19:20 +0200 Subject: [PATCH] make a real project structure --- .gitignore | 2 ++ gpm.cabal | 50 ++++++++++++++++++++++++++++++++++ package.yaml | 42 ++++++++++++++++++++++++++++ src-exe/Main.hs | 9 ++++++ gpm.hs => src/GPM.hs | 36 ++++++++++-------------- src/GPM/Review.hs | 28 +++++++++++++++++++ stack.yaml | 65 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 210 insertions(+), 22 deletions(-) create mode 100644 .gitignore create mode 100644 gpm.cabal create mode 100644 package.yaml create mode 100644 src-exe/Main.hs rename gpm.hs => src/GPM.hs (60%) create mode 100644 src/GPM/Review.hs create mode 100644 stack.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e3b6ba2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.stack-work +.dir-locals.el \ No newline at end of file diff --git a/gpm.cabal b/gpm.cabal new file mode 100644 index 0000000..8b79436 --- /dev/null +++ b/gpm.cabal @@ -0,0 +1,50 @@ +-- This file has been generated from package.yaml by hpack version 0.28.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: a686a36064ef8ecb9b6b995eff90b19c3c02223326995cc6f0ae33c7f7d699f5 + +name: gpm +version: 0.1.0.0 +category: Test +stability: alpha (experimental) +author: Yann Esposito +maintainer: yann.esposito@gmail.com +copyright: © 2017 Yann Esposito +license: ISC +build-type: Simple +cabal-version: >= 1.10 +extra-source-files: + README.org + stack.yaml + +library + exposed-modules: + GPM + GPM.Review + other-modules: + Paths_gpm + hs-source-dirs: + src + default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables Strict + ghc-options: -O2 -Werror -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances + build-depends: + base >=4.8 && <5 + , protolude + , turtle + default-language: Haskell2010 + +executable gpm + main-is: Main.hs + other-modules: + Paths_gpm + hs-source-dirs: + src-exe + default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables Strict + 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 + , gpm + , protolude + , turtle + default-language: Haskell2010 diff --git a/package.yaml b/package.yaml new file mode 100644 index 0000000..a4c0d9f --- /dev/null +++ b/package.yaml @@ -0,0 +1,42 @@ +name: gpm +version: '0.1.0.0' +category: Test +author: Yann Esposito +maintainer: yann.esposito@gmail.com +copyright: © 2017 Yann Esposito +license: ISC +url: https://gitlab.esy.fun/yogsototh/gpm +default-extensions: + - OverloadedStrings + - NoImplicitPrelude + - ScopedTypeVariables + - Strict +extra-source-files: +- README.org +- stack.yaml +ghc-options: +- -O2 +- -Werror +- -Wall +- -Wcompat +- -Wincomplete-uni-patterns +- -Wredundant-constraints +- -Wnoncanonical-monad-instances +dependencies: +- base >=4.8 && <5 +- protolude +- turtle +library: + source-dirs: src +executables: + gpm: + main: Main.hs + source-dirs: src-exe + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + - -optP-Wno-nonportable-include-path + dependencies: + - gpm +stability: alpha (experimental) diff --git a/src-exe/Main.hs b/src-exe/Main.hs new file mode 100644 index 0000000..16fda3e --- /dev/null +++ b/src-exe/Main.hs @@ -0,0 +1,9 @@ +module Main +where + +import Protolude + +import GPM (gpm) + +main :: IO () +main = gpm diff --git a/gpm.hs b/src/GPM.hs similarity index 60% rename from gpm.hs rename to src/GPM.hs index ff0c9e6..c4c851e 100755 --- a/gpm.hs +++ b/src/GPM.hs @@ -1,44 +1,36 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i runghc -#! nix-shell -p "ghc.withPackages (ps: [ ps.protolude ps.turtle ])" -#! nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/16d475334409f7fa632929b2838421b4ffe34927.tar.gz" {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} +module GPM +where + import Protolude hiding (stdout,(%),die) import Turtle -main :: IO () -main = do - x <- options "Git Project Manager" parser - case x of +import GPM.Review (handleReview,ReviewCommand(..),parseReviewCmd) + +gpm :: IO () +gpm = do + subcmd <- options "Git Project Manager" parser + case subcmd of Init -> init NewIssue -> newIssue - StartReview br -> startReview br - EndReview br -> endReview br + Review reviewCmd -> handleReview reviewCmd data Command = Init | NewIssue - | StartReview (Maybe Text) - | EndReview (Maybe Text) + | Review ReviewCommand deriving (Eq) parser :: Parser Command parser = subcommand "init" "Initialize gpm" (pure Init) <|> subcommand "new-issue" "Create a new Issue" (pure NewIssue) - <|> StartReview <$> subcommand "start-review" "Start review (use current branch by default)" - (optional (argText "branch" "The git branch to review")) - <|> EndReview <$> subcommand "end-review" "End review (use current branch by default)" - (optional (argText "branch" "The git branch to end review")) + <|> Review <$> subcommand "review" + "Review (use current branch by default)" + parseReviewCmd newIssue :: IO () newIssue = die "TODO" -startReview :: Maybe Text -> IO () -startReview br = die "TODO" - -endReview :: Maybe Text -> IO () -endReview br = die "TODO" - init :: IO () init = do echo "# -- Git Project Manager" diff --git a/src/GPM/Review.hs b/src/GPM/Review.hs new file mode 100644 index 0000000..fa0efed --- /dev/null +++ b/src/GPM/Review.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE OverloadedStrings #-} +module GPM.Review where + +import Protolude hiding (stdout,die) +import Turtle + +data ReviewCommand = ReviewStart (Maybe Text) + | ReviewStop (Maybe Text) + | ReviewAccept + | ReviewFeedback + | ReviewQuestion + | ReviewReject + deriving (Eq) + +parseReviewCmd :: Parser ReviewCommand +parseReviewCmd = subcommand "accept" "Accept the merge" (pure ReviewAccept) + <|> subcommand "feedback" "Provide a feedback" (pure ReviewFeedback) + <|> subcommand "question" "Ask a question" (pure ReviewQuestion) + <|> subcommand "reject" "Ask a question" (pure ReviewReject) + +handleReview :: ReviewCommand -> IO () +handleReview (ReviewStart _br) = die "TODO" +handleReview (ReviewStop _br ) = die "TODO" +handleReview ReviewAccept = die "TODO" +handleReview ReviewFeedback = die "TODO" +handleReview ReviewQuestion = die "TODO" +handleReview ReviewReject = die "TODO" diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..a889955 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,65 @@ +# This file was automatically generated by 'stack init' +# +# Some commonly used options have been documented as comments in this file. +# For advanced use and comprehensive documentation of the format, please see: +# https://docs.haskellstack.org/en/stable/yaml_configuration/ + +# Resolver to choose a 'specific' stackage snapshot or a compiler version. +# A snapshot resolver dictates the compiler version and the set of packages +# to be used for project dependencies. For example: +# +# resolver: lts-3.5 +# resolver: nightly-2015-09-21 +# resolver: ghc-7.10.2 +# resolver: ghcjs-0.1.0_ghc-7.10.2 +# +# The location of a snapshot can be provided as a file or url. Stack assumes +# a snapshot provided as a file might change, whereas a url resource does not. +# +# resolver: ./custom-snapshot.yaml +# resolver: https://example.com/snapshots/2018-01-01.yaml +resolver: lts-12.8 + +# User packages to be built. +# Various formats can be used as shown in the example below. +# +# packages: +# - some-directory +# - https://example.com/foo/bar/baz-0.0.2.tar.gz +# - location: +# git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# subdirs: +# - auto-update +# - wai +packages: +- . +# Dependency packages to be pulled from upstream that are not in the resolver +# using the same syntax as the packages field. +# (e.g., acme-missiles-0.3) +# extra-deps: [] + +# Override default flag values for local packages and extra-deps +# flags: {} + +# Extra package databases containing global packages +# extra-package-dbs: [] + +# Control whether we use the GHC we find on the path +# system-ghc: true +# +# Require a specific version of stack, using version ranges +# require-stack-version: -any # Default +# require-stack-version: ">=1.7" +# +# Override the architecture used by stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor \ No newline at end of file