Skip to content

Commit

Permalink
Show version with --version
Browse files Browse the repository at this point in the history
  • Loading branch information
nmattia committed Sep 7, 2020
1 parent 6ae4c77 commit b50a010
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ Usage: niv [-s|--sources-file FILE] COMMAND
Available options:
-s,--sources-file FILE Use FILE instead of nix/sources.json
-h,--help Show this help text
--version Print version
Available commands:
init Initialize a Nix project. Existing files won't be
Expand Down
4 changes: 1 addition & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ let
packages = ps: [ ps.niv ];
shellHook = ''
repl_for() {
haskell_version=$(cat ./package.yaml \
| grep -oP 'version: \K\d+.\d+.\d+' \
| sed 's/\./,/g' )
haskell_version=$(jq <./package.yaml -cMr '.version' | sed 's/\./,/g')
paths_niv=$(mktemp -d)/Paths_niv.hs
Expand Down
7 changes: 6 additions & 1 deletion src/Niv/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ cli = do
Opts.Failure $
Opts.parserFailure pprefs pinfo Opts.ShowHelpText mempty
execParserPure' pprefs pinfo args = Opts.execParserPure pprefs pinfo args
opts = Opts.info ((,) <$> parseFindSourcesJson <*> (parseCommand <**> Opts.helper)) $ mconcat desc
opts = Opts.info ((,) <$> parseFindSourcesJson <*> (parseCommand <**> Opts.helper <**> versionflag)) $ mconcat desc
desc =
[ Opts.fullDesc,
Opts.headerDoc $ Just $
Expand All @@ -78,6 +78,11 @@ cli = do
<> Opts.help "Use FILE instead of nix/sources.json"
)
<|> pure Auto
versionflag :: Opts.Parser (a -> a)
versionflag =
Opts.abortOption (Opts.InfoMsg (showVersion version)) $
mconcat
[Opts.long "version", Opts.hidden, Opts.help "Print version"]

parseCommand :: Opts.Parser (NIO ())
parseCommand =
Expand Down

0 comments on commit b50a010

Please sign in to comment.