Skip to content

Commit

Permalink
version bump and error info string trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilGedda committed Nov 14, 2016
1 parent d65919c commit c1acbcf
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 60 deletions.
6 changes: 3 additions & 3 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ newtype Hattis a = Hattis {
} deriving (Monad, Applicative, Functor, MonadIO,
MonadError HattisError, MonadWriter [String])

hattisver = "v1.0.0"
versionstr = "Hattis " ++ hattisver ++"\nCopyright (C) 2016 Emil Gedda"
hattisver = "v1.1.0"
versionstr = "Hattis " ++ hattisver ++"\nCopyright (C) 2015-2016 Emil Gedda"

data Input = Input { probid :: String, files :: [String],
conf :: Maybe String, force :: Bool,
Expand Down Expand Up @@ -213,7 +213,7 @@ progress silent p f prev disp = do
display nocolor noglyphs hasfailed (Running passed tot) = do
putStr "\r[ "
let pass = if noglyphs then 'P' else ''
let fail = 'X'
let fail = if noglyphs then 'X' else ''
let unkw = '-'

condapply nocolor (colorme Green) . putStr $ replicate (fromIntegral passed) pass
Expand Down
114 changes: 59 additions & 55 deletions hattis.cabal
Original file line number Diff line number Diff line change
@@ -1,61 +1,65 @@
name: hattis
version: 1.0.0.0
synopsis: A cli-interface to the online coding judge kattis.com
description: Please see README.md
homepage: http://github.com/emilgedda/hattis#readme
license: Apache-2.0
license-file: LICENSE
author: Emil Gedda
maintainer: emil.gedda@emilgedda.se
copyright: 2015 Emil Gedda
category: Network
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
name: hattis
version: 1.0.0.0
cabal-version: >=1.10
build-type: Simple
license: BSD-3
license-file: LICENSE
copyright: 2015-2016 Emil Gedda
maintainer: emil.gedda@emilgedda.se
homepage: http://github.com/emilgedda/hattis#readme
synopsis: A cli-interface to the online coding judge kattis.com
description:
Please see README.md
category: Network
author: Emil Gedda

source-repository head
type: git
location: https://github.com/emilgedda/hattis

library
hs-source-dirs: src,
src/Hattis
exposed-modules: Hattis.Error
, Hattis.Network
, Hattis.Text.Ini
, Hattis.Text.Make
, Hattis.Text.SourceFile
build-depends: base >= 4.7 && < 5
, utf8-string >= 1.0 && < 1.1
, bytestring >= 0.10 && < 0.11
, containers >= 0.5 && < 0.6
, directory >= 1.2 && < 1.3
, filepath >= 1.4 && < 1.5
, http-client >= 0.4 && < 0.6
, http-conduit >= 2.1 && < 2.3
, megaparsec >= 4.4 && < 5.0
, mtl >= 2.2 && < 2.3
, optparse-applicative >= 0.12 && < 0.13
, hxt >= 9.3 && < 9.4
, free
default-language: Haskell2010
exposed-modules:
Hattis.Error
Hattis.Network
Hattis.Text.Ini
Hattis.Text.Make
Hattis.Text.SourceFile
build-depends:
base >=4.9.0.0 && <4.10,
utf8-string >=1.0.1.1 && <1.1,
bytestring >=0.10.8.1 && <0.11,
containers >=0.5.7.1 && <0.6,
directory >=1.2.6.2 && <1.3,
filepath >=1.4.1.0 && <1.5,
http-client >=0.4.31.1 && <0.5,
http-conduit >=2.1.11 && <2.2,
megaparsec >=5.0.1 && <5.1,
mtl >=2.2.1 && <2.3,
optparse-applicative >=0.12.1.0 && <0.13,
hxt >=9.3.1.16 && <9.4,
text >=1.2.2.1 && <1.3,
free >=4.12.4 && <4.13
default-language: Haskell2010
hs-source-dirs: src src/Hattis

executable hattis
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N -O2
build-depends: base
, hattis
, mtl
, ansi-terminal
, optparse-applicative >= 0.12 && <= 0.15
default-language: Haskell2010
main-is: Main.hs
build-depends:
base >=4.9.0.0 && <4.10,
hattis >=1.0.0.0 && <1.1,
mtl >=2.2.1 && <2.3,
ansi-terminal >=0.6.2.3 && <0.7,
optparse-applicative >=0.12 && <=0.15
default-language: Haskell2010
hs-source-dirs: app
ghc-options: -threaded -rtsopts -with-rtsopts=-N

test-suite hattis-test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Spec.hs
build-depends: base
, hattis
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010

source-repository head
type: git
location: https://github.com/emilgedda/hattis
type: exitcode-stdio-1.0
main-is: Spec.hs
build-depends:
base >=4.9.0.0 && <4.10,
hattis >=1.0.0.0 && <1.1
default-language: Haskell2010
hs-source-dirs: test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
4 changes: 3 additions & 1 deletion src/Hattis/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Text.XML.HXT.Core
import qualified Control.Monad as M
import qualified Data.ByteString.Lazy.UTF8 as LB
import qualified Data.ByteString.UTF8 as B
import qualified Data.Text as T

data SubmissionProgress
= Compiling
Expand Down Expand Up @@ -154,7 +155,8 @@ parseFailed doc status = liftIO $ do
return $ Failed status errinf hints compinf
where fetch txt = extract <$> runX (doc >>> deep (extrainfo txt) /> getChildren >>> getText)
extrainfo txt = isElem >>> hasName "div" </ (hasName "h3" /> hasText (==txt))
extract x = replace "\\n" "\n" . replace "\\t" "\t" <$> (listToMaybe $ drop 1 x)
extract x = trim . replace "\\n" "\n" . replace "\\t" "\t" <$> (listToMaybe $ drop 1 x)
trim = T.unpack . T.strip . T.pack

parseStatus :: MonadIO m => IOStateArrow () XmlTree XmlTree -> m String
parseStatus doc = liftIO $ safe <$> runX (doc >>> deep stat //> getText)
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-6.3
resolver: lts-7.9

# Local packages, usually specified by relative directory name
packages:
Expand Down

0 comments on commit c1acbcf

Please sign in to comment.