1
1
mirror of https://github.com/nmattia/niv.git synced 2024-09-18 19:07:19 +03:00

Merge pull request #135 from nmattia/nm-help-no-args

Show help when no arguments are given
This commit is contained in:
Nicolas Mattia 2019-10-30 16:46:46 +01:00 committed by GitHub
commit 88d6f20882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ import Niv.Update
import System.Exit (ExitCode(ExitSuccess))
import System.FilePath ((</>), takeDirectory)
import System.Process (readProcessWithExitCode)
import System.Environment (getArgs)
import UnliftIO
import Data.Version (showVersion)
import qualified Data.Aeson as Aeson
@ -41,9 +42,14 @@ import qualified System.Directory as Dir
import Paths_niv (version)
cli :: IO ()
cli = join $ Opts.execParser opts
cli = join $
execParserPure' Opts.defaultPrefs opts <$> getArgs
>>= Opts.handleParseResult
where
opts = Opts.info (parseCommand <**> Opts.helper) $ mconcat desc
execParserPure' pprefs pinfo [] = Opts.Failure $
Opts.parserFailure pprefs pinfo Opts.ShowHelpText mempty
execParserPure' pprefs pinfo args = Opts.execParserPure pprefs pinfo args
opts = Opts.info (parseCommand <**> Opts.helper ) $ mconcat desc
desc =
[ Opts.fullDesc
, Opts.headerDoc $ Just $