-
Notifications
You must be signed in to change notification settings - Fork 6
/
Main.hs
57 lines (50 loc) · 1.7 KB
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
-- Module : Main
-- Copyright : (c) 2015 Knewton, Inc <se@knewton.com>
-- (c) 2015 Tim Dysinger <tim@dysinger.net> (contributor)
-- License : Apache 2.0 http://opensource.org/licenses/Apache-2.0
-- Maintainer : Tim Dysinger <tim@dysinger.net>
-- Stability : experimental
-- Portability : non-portable (GHC extensions)
import BasePrelude
import Data.Time
import Distribution.PackageDescription.TH
import Git.Embed
import Language.Haskell.TH
import Options.Applicative
import Rifactor.Plan
import Rifactor.Types
version :: String
version = $(packageVariable (pkgVersion . package))
gitRev :: String
gitRev = $(embedGitShortRevision)
buildDate :: String
buildDate =
$(stringE =<<
runIO (show `fmap` Data.Time.getCurrentTime))
parserInfo :: ParserInfo Options
parserInfo =
info (helper <*>
(Options <$>
(strOption (long "config-file" <>
short 'c' <>
metavar "FILE" <>
help "Read JSON config from FILE") <|>
pure "/etc/rifactor/config.json") <*>
(switch (long "dry-run" <>
short 'd' <>
help "Print instead of running")) <*>
(switch (long "verbose" <>
short 'v' <>
help "Show trace-level AWS data"))))
(fullDesc <>
header (("RIFactor " ++ version) ++
(" | Source: " ++ gitRev) ++
(" | Built: " ++ buildDate)) <>
progDesc "Optimize AWS Reserved Instances")
main :: IO ()
main = execParser parserInfo >>= exec