mirror of
https://github.com/Avi-D-coder/implicit-hie.git
synced 2024-11-22 17:55:51 +03:00
Merge pull request #15 from DunetsNM/feature/cmd-line-cabal-stack-switch
--cabal and --stack command line switches
This commit is contained in:
commit
eb606df6c3
25
app/Main.hs
25
app/Main.hs
@ -15,17 +15,12 @@ import Hie.Yaml
|
||||
import System.Directory
|
||||
import System.Directory.Internal
|
||||
import System.FilePath.Posix
|
||||
import System.Environment
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
pwd <- getCurrentDirectory
|
||||
files <- listDirectory pwd
|
||||
let name =
|
||||
if | any (("dist-newstyle" ==) . takeFileName) files -> "cabal"
|
||||
| any ((".stack-work" ==) . takeFileName) files -> "stack"
|
||||
| any (("cabal.project" ==) . takeFileName) files -> "cabal"
|
||||
| any (("stack.yaml" ==) . takeFileName) files -> "stack"
|
||||
| otherwise -> "cabal"
|
||||
name <- resolveName pwd
|
||||
cfs <- runMaybeT $ case name of
|
||||
"cabal" -> cabalPkgs pwd
|
||||
_ -> stackYamlPkgs pwd
|
||||
@ -35,3 +30,19 @@ main = do
|
||||
<> "\n You may need to run stack build."
|
||||
pkgs <- catMaybes <$> mapM (nestedPkg pwd) (concat cfs)
|
||||
putStr <$> hieYaml name $ fmtPkgs name pkgs
|
||||
|
||||
resolveName :: FilePath -> IO String
|
||||
resolveName pwd = do
|
||||
args <- getArgs
|
||||
files <- listDirectory pwd
|
||||
let fileNames = map takeFileName files
|
||||
name =
|
||||
if | "--cabal" `elem` args -> "cabal"
|
||||
| "--stack" `elem` args -> "stack"
|
||||
| "dist-newstyle" `elem` fileNames -> "cabal"
|
||||
| ".stack-work" `elem` fileNames -> "stack"
|
||||
| "cabal.project" `elem` fileNames -> "cabal"
|
||||
| "stack.yaml" `elem` fileNames -> "stack"
|
||||
| otherwise -> "cabal"
|
||||
return name
|
||||
|
||||
|
12
hie.yaml.cbl
Normal file
12
hie.yaml.cbl
Normal file
@ -0,0 +1,12 @@
|
||||
# Rename this file to hie.yaml to open this project in HIE and use Cabal as build system
|
||||
|
||||
cradle:
|
||||
cabal:
|
||||
- path: "src"
|
||||
component: "lib:implicit-hie"
|
||||
|
||||
- path: "app/Main.hs"
|
||||
component: "implicit-hie:exe:gen-hie"
|
||||
|
||||
- path: "test"
|
||||
component: "implicit-hie:test:implicit-hie-test"
|
12
hie.yaml.stack
Normal file
12
hie.yaml.stack
Normal file
@ -0,0 +1,12 @@
|
||||
# Rename this file to hie.yaml to open this project in HIE and use Stack as build system
|
||||
|
||||
cradle:
|
||||
stack:
|
||||
- path: "./src"
|
||||
component: "implicit-hie:lib"
|
||||
|
||||
- path: "./app/Main.hs"
|
||||
component: "implicit-hie:exe:gen-hie"
|
||||
|
||||
- path: "./test"
|
||||
component: "implicit-hie:test:implicit-hie-test"
|
Loading…
Reference in New Issue
Block a user