chshersh / iris

🌈 Haskell CLI Framework supporting Command Line Interface Guidelines
https://hackage.haskell.org/package/iris
Mozilla Public License 2.0
182 stars 22 forks source link

resolves #16 write usage example using Literate Haskell #16 #87

Closed Dponya closed 1 year ago

Dponya commented 1 year ago

Resolves #16

Well. It seems like that my current implementation have problems with requirement in issue: lines numbers to stderr and with lines to stdout (to mimic the output of ripgrep)

I've seen a ripgrep and implemented it like that:

occurencesPrinter :: [(Int, T.Text)] -> App ()
occurencesPrinter = mapM_ unpack
    where
        unpack :: (Int, T.Text) -> App ()
        unpack (idx, line) = do
            liftIO $ printIdx idx
            liftIO $ putStr ":"
            printLine line

        printIdx idx = putStr $ " " ++ show idx

        printLine :: T.Text -> App ()
        printLine x = Iris.putStdoutColouredLn
            (Colourista.formatWith [Colourista.yellow, Colourista.bold])
                $ BSL.toStrict $ TLE.encodeUtf8 x

And in this function I used putStr for output like that:

2:Ipsum lorem lorem mole

Where the line number is putted right after Iris.putStdoutColouredLn output. Maybe it breaks requirements with stderr and stdout, if it is, how to avoid it? I really don't have an idea to implement it in another way to include using Colourista to print it the right way with colors.

And I'm sure that the documentation in examples/simple-grep/README.md has serious problems with explanation, if it is, please leave in the comments proposals to fix it.

Thanks you!

Dponya commented 1 year ago

@chshersh Hi! Are there some problems with PR or CI pipelines? I've checked building of Iris on several ghc versions that were included into build, everything goes fine locally. Should I fix something?

chshersh commented 1 year ago

Hi @Dponya 👋🏻

Sorry, I haven't reviewed this PR yet. I've been very busy with personal stuff and tons of other PRs during Hacktoberfest 🥴

From CI logs, I can see that the markdown-unlit preprocessor is not configured properly. You need to add it to the build-tool-depends section instead of build-depends to make it work on a newer Cabal. See an example here:

Dponya commented 1 year ago

The tutorial looks great! There's always room for improvement but I left a few main suggestions on how to improve the docs slightly_smiling_face

And see my comment before on fixing CI.

Thanks! Truly talk, I was unsatisfied with the quality of the documentation. So, I took look at the co-log example and was inspired by those tutorial's structure. Unfortunately, I delivered updates while you taking a review on PR. :sweat_smile:

So, I pushed new fixes that maybe fit the above proposals.