Skip to content

Commit

Permalink
Update documentation, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
psibi committed Oct 20, 2019
1 parent 2b6be07 commit ec0f029
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* Make it obey --platform option
* Add -u as an alias for --update

* Make parsing more robust

# 0.5.1

Expand All @@ -12,7 +12,7 @@

* Obey XdgData for storing the files.
* Also search pages from sunos directory now.
* Support subcommansds ie. tldr git submodule will now work.
* Support subcommands ie. tldr git submodule will now work.

# 0.4.0.2

Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,35 @@ Haskell client for tldr
$ tldr --help
tldr - Simplified and community-driven man pages

Usage: tldr [-v|--version] [--update] COMMAND
Usage: tldr [-v|--version] ((-u|--update) | [-p|--platform PLATFORM] COMMAND)
tldr Client program

Available options:
-h,--help Show this help text
-v,--version Show version
--update Update tldr pages
-u,--update Update offline cache of tldr pages
-p,--platform PLATFORM Prioritize specfic platform while searching. Valid
values include linux, osx, windows, sunos
COMMAND name of the command
```

Or a much better example of the usage:

``` shellsession
$ tldr tldr
tldr
Simplified man pages.More information: https://tldr.sh.

- Get typical usages of a command (hint: this is how you got here!):
tldr {{command}}

- Show the tar tldr page for linux:
tldr -p {{linux}} {{tar}}

- Get help for a git subcommand:
tldr {{git checkout}}
```

## Snapshot

![tldr](https://cloud.githubusercontent.com/assets/737477/24076451/2a5a604c-0c57-11e7-9bf7-13d76e8e7f12.png)
33 changes: 29 additions & 4 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE BangPatterns #-}

module Main
( main
Expand All @@ -8,6 +9,7 @@ module Main
import Control.Monad
import Data.List (intercalate)
import Data.Semigroup ((<>))
import qualified Data.Set as Set
import Data.Version (showVersion)
import GHC.IO.Handle.FD (stdout)
import Options.Applicative
Expand Down Expand Up @@ -39,7 +41,10 @@ programOptions :: Parser TldrOpts
programOptions = (TldrOpts <$> (updateIndexCommand <|> viewPageCommand))

updateIndexCommand :: Parser TldrCommand
updateIndexCommand = flag' UpdateIndex (long "update" <> short 'u')
updateIndexCommand =
flag'
UpdateIndex
(long "update" <> short 'u' <> help "Update offline cache of tldr pages")

viewOptionsParser :: Parser ViewOptions
viewOptionsParser = ViewOptions <$> platformFlag
Expand All @@ -51,7 +56,15 @@ viewPageCommand =

platformFlag :: Parser (Maybe String)
platformFlag =
optional (strOption (long "platform" <> short 'p' <> metavar "PLATFORM"))
optional
(strOption
(long "platform" <> short 'p' <> metavar "PLATFORM" <>
help
("Prioritize specfic platform while searching. Valid values include " <>
platformHelpValue)))
where
platformHelpValue :: String
platformHelpValue = intercalate ", " platformDirs

tldrDirName :: String
tldrDirName = "tldr"
Expand All @@ -60,7 +73,10 @@ repoHttpsUrl :: String
repoHttpsUrl = "https://github.com/tldr-pages/tldr.git"

checkDirs :: [String]
checkDirs = ["common", "linux", "osx", "windows", "sunos"]
checkDirs = "common" : platformDirs

platformDirs :: [String]
platformDirs = ["linux", "osx", "windows", "sunos"]

tldrInitialized :: IO Bool
tldrInitialized = do
Expand Down Expand Up @@ -120,7 +136,16 @@ getCheckDirs :: ViewOptions -> [String]
getCheckDirs voptions =
case platformOption voptions of
Nothing -> checkDirs
Just platform -> ["common", platform]
Just platform -> nubOrd $ ["common", platform] <> checkDirs

-- | Strip out duplicates
nubOrd :: Ord a => [a] -> [a]
nubOrd = loop mempty
where
loop _ [] = []
loop !s (a:as)
| a `Set.member` s = loop s as
| otherwise = a : loop (Set.insert a s) as

handleTldrOpts :: TldrOpts -> IO ()
handleTldrOpts TldrOpts {..} = do
Expand Down
5 changes: 3 additions & 2 deletions tldr.cabal
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: tldr
version: 0.5.1
version: 0.6.0
synopsis: Haskell tldr client
description: Haskell tldr client with support for viewing tldr pages. Has offline
cache for accessing pages.
cache for accessing pages. Visit https://tldr.sh for more details.
homepage: https://github.com/psibi/tldr-hs#readme
license: BSD3
license-file: LICENSE
Expand Down Expand Up @@ -36,6 +36,7 @@ executable tldr
, filepath
, typed-process
, semigroups
, containers
default-language: Haskell2010

test-suite tldr-test
Expand Down

0 comments on commit ec0f029

Please sign in to comment.