rollbar-cli (empty) → 0.1.0
raw patch · 8 files changed
+205/−0 lines, 8 filesdep +basedep +optparse-applicativedep +rollbar-clisetup-changed
Dependencies added: base, optparse-applicative, rollbar-cli, rollbar-client
Files
- ChangeLog.md +3/−0
- LICENSE +19/−0
- README.md +7/−0
- Setup.hs +2/−0
- app/Main.hs +11/−0
- rollbar-cli.cabal +69/−0
- src/Rollbar/CLI.hs +92/−0
- test/Spec.hs +2/−0
+ ChangeLog.md view
@@ -0,0 +1,3 @@+# Changelog for rollbar-cli++## Unreleased changes
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright 2020 Stack Builders Inc.++Permission is hereby granted, free of charge, to any person obtaining a copy of+this software and associated documentation files (the "Software"), to deal in+the Software without restriction, including without limitation the rights to+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies+of the Software, and to permit persons to whom the Software is furnished to do+so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
+ README.md view
@@ -0,0 +1,7 @@+# Rollbar CLI++Simple CLI tool to perform commons tasks such as tracking deploys.++## Getting Started++Read instructions [here](../README.md).
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ app/Main.hs view
@@ -0,0 +1,11 @@+module Main+ ( main+ ) where++import Rollbar.CLI (parseCommand, runCommand)+import Rollbar.Client (readSettings)++main :: IO ()+main = do+ settings <- readSettings "rollbar.yaml"+ parseCommand >>= runCommand settings
+ rollbar-cli.cabal view
@@ -0,0 +1,69 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.34.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 550be30f2b0d05cb1448d3ac2048f42b360608d96c8bd70aa2815abe73fb9c08++name: rollbar-cli+version: 0.1.0+synopsis: Simple CLI tool to perform commons tasks such as tracking deploys.+description: Please see the README on GitHub at+ <https://github.com/stackbuilders/rollbar-haskell/tree/master/rollbar-cli>+homepage: https://github.com/stackbuilders/rollbar-haskell#readme+bug-reports: https://github.com/stackbuilders/rollbar-haskell/issues+author: Stack Builders Inc.+maintainer: Sebastián Estrella <sestrella@stackbuilders.com>+copyright: 2020 Stack Builders Inc.+license: MIT+license-file: LICENSE+tested-with: GHC ==8.6.5, GHC ==8.8.4, GHC ==8.10.2+build-type: Simple+extra-source-files:+ README.md+ ChangeLog.md++source-repository head+ type: git+ location: https://github.com/stackbuilders/rollbar-haskell++library+ exposed-modules:+ Rollbar.CLI+ other-modules:+ Paths_rollbar_cli+ hs-source-dirs:+ src+ ghc-options: -Wall+ build-depends:+ base >=4.12 && <5+ , optparse-applicative >=0.14 && <1+ , rollbar-client >=0.1 && <1+ default-language: Haskell2010++executable rollbar+ main-is: Main.hs+ other-modules:+ Paths_rollbar_cli+ hs-source-dirs:+ app+ ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base >=4.12 && <5+ , rollbar-cli+ , rollbar-client+ default-language: Haskell2010++test-suite spec+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ other-modules:+ Paths_rollbar_cli+ hs-source-dirs:+ test+ ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base >=4.12 && <5+ , rollbar-cli+ default-language: Haskell2010
+ src/Rollbar/CLI.hs view
@@ -0,0 +1,92 @@+-- |+-- Module: Rollbar.CLI+-- Copyright: (c) 2020 Stack Builders Inc.+-- License: MIT+-- Maintainer: Sebastián Estrella <sestrella@stackbuilders.com>+module Rollbar.CLI+ ( Command(..)+ , DeployCommand(..)+ , parseCommand+ , runCommand+ ) where++import Options.Applicative+import Rollbar.Client++data Command+ = CommandPing+ -- ^ Pings Rollbar API server.+ --+ -- @since 0.1.0+ | CommandDeploy DeployCommand+ -- ^ Tracks a deploy in Rollbar.+ --+ -- @since 0.1.0+ deriving (Eq, Show)++data DeployCommand = DeployCommandReport (Maybe Revision)+ deriving (Eq, Show)++-- | Parses a 'Command'.+--+-- @since 0.1.0+parseCommand :: IO Command+parseCommand = execParser commandParserInfo++commandParserInfo :: ParserInfo Command+commandParserInfo = info (commandParser <**> helper) $ mconcat+ [ fullDesc+ , progDesc "Simple CLI to talk with Rollbar API"+ ]++commandParser :: Parser Command+commandParser = subparser $ mconcat+ [ command "ping" $ info (pingParser <**> helper) $ mconcat+ [ fullDesc+ , progDesc "Ping the API server"+ ]+ , command "deploy" $ info (deployParser <**> helper) $ mconcat+ [ fullDesc+ , progDesc "Deploy specific commands"+ ]+ ]+ where+ pingParser = pure CommandPing+ deployParser = CommandDeploy <$> deployCommandParser++deployCommandParser :: Parser DeployCommand+deployCommandParser = subparser $+ command "report" $ info (deployCommandReportParser <**> helper) $ mconcat+ [ fullDesc+ , progDesc "Tracks a deploy in Rollbar"+ ]++deployCommandReportParser :: Parser DeployCommand+deployCommandReportParser =+ DeployCommandReport <$> optional (Revision <$> strOption revisionOptions)+ where+ revisionOptions = mconcat+ [ short 'r'+ , long "revision"+ , help $ mconcat+ [ "Git SHA of revision being deployed, if this argument is not present"+ , " it would try to get the value from the configuration file first"+ , " before calling git."+ ]+ ]++runCommand :: Settings -> Command -> IO ()+runCommand settings cmd = do+ case cmd of+ CommandPing -> do+ pong <- runRollbar settings ping+ print pong+ CommandDeploy (DeployCommandReport mrevision) -> do+ deployId <- runRollbar settings $ do+ revision <- case mrevision of+ Nothing -> getRevision+ Just revision -> return revision+ deploy <- mkDeploy revision+ reportDeploy deploy++ print deployId
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"