Skip to content

Commit

Permalink
Update to optparse-applicative 0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
ncfavier committed Jan 23, 2024
1 parent b0ad17b commit a1c35f7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 33 deletions.
44 changes: 25 additions & 19 deletions src/Niv/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ cli = do
[ Opts.fullDesc,
Opts.headerDoc $
Just $
"niv - dependency manager for Nix projects"
Opts.<$$> ""
Opts.<$$> "version:"
Opts.<+> Opts.text (showVersion version)
Opts.vcat
[ "niv - dependency manager for Nix projects",
"",
"version:"
Opts.<+> Opts.pretty (showVersion version)
]
]
parseFindSourcesJson =
AtPath
Expand Down Expand Up @@ -420,13 +422,13 @@ parseCmdUpdate =
Opts.headerDoc $
Just $
Opts.nest 2 $
"Examples:"
Opts.<$$> ""
Opts.<$$> Opts.vcat
[ Opts.fill 30 "niv update" Opts.<+> "# update all packages",
Opts.fill 30 "niv update nixpkgs" Opts.<+> "# update nixpkgs",
Opts.fill 30 "niv update my-package -v beta-0.2" Opts.<+> "# update my-package to version \"beta-0.2\""
]
Opts.vcat
[ "Examples:",
"",
Opts.fill 30 "niv update" Opts.<+> "# update all packages",
Opts.fill 30 "niv update nixpkgs" Opts.<+> "# update nixpkgs",
Opts.fill 30 "niv update my-package -v beta-0.2" Opts.<+> "# update my-package to version \"beta-0.2\""
]
]

specToFreeAttrs :: PackageSpec -> Attrs
Expand Down Expand Up @@ -510,10 +512,12 @@ parseCmdModify =
Opts.progDesc "Modify dependency attributes without performing an update",
Opts.headerDoc $
Just $
"Examples:"
Opts.<$$> ""
Opts.<$$> " niv modify nixpkgs -v beta-0.2"
Opts.<$$> " niv modify nixpkgs -a branch=nixpkgs-unstable"
Opts.vcat
[ "Examples:",
"",
" niv modify nixpkgs -v beta-0.2",
" niv modify nixpkgs -a branch=nixpkgs-unstable"
]
]
optName =
Opts.optional $
Expand Down Expand Up @@ -559,10 +563,12 @@ parseCmdDrop =
Opts.progDesc "Drop dependency",
Opts.headerDoc $
Just $
"Examples:"
Opts.<$$> ""
Opts.<$$> " niv drop jq"
Opts.<$$> " niv drop my-package version"
Opts.vcat
[ "Examples:",
"",
" niv drop jq",
" niv drop my-package version"
]
]
parseDropAttributes :: Opts.Parser [T.Text]
parseDropAttributes =
Expand Down
14 changes: 8 additions & 6 deletions src/Niv/Git/Cmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ describeGit =
Opts.progDesc "Add a git dependency. Experimental.",
Opts.headerDoc $
Just $
"Examples:"
Opts.<$$> ""
Opts.<$$> " niv add git git@github.com:stedolan/jq"
Opts.<$$> " niv add git ssh://git@github.com/stedolan/jq --rev deadb33f"
Opts.<$$> " niv add git https://github.com/stedolan/jq.git"
Opts.<$$> " niv add git --repo /my/custom/repo --name custom --branch development"
Opts.vcat
[ "Examples:",
"",
" niv add git git@github.com:stedolan/jq",
" niv add git ssh://git@github.com/stedolan/jq --rev deadb33f",
" niv add git https://github.com/stedolan/jq.git",
" niv add git --repo /my/custom/repo --name custom --branch development"
]
]

gitUpdate ::
Expand Down
12 changes: 7 additions & 5 deletions src/Niv/GitHub/Cmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ describeGitHub =
Opts.progDesc "Add a GitHub dependency",
Opts.headerDoc $
Just $
"Examples:"
Opts.<$$> ""
Opts.<$$> " niv add stedolan/jq"
Opts.<$$> " niv add NixOS/nixpkgs -n nixpkgs -b nixpkgs-unstable"
Opts.<$$> " niv add my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip"
Opts.vcat
[ "Examples:",
"",
" niv add stedolan/jq",
" niv add NixOS/nixpkgs -n nixpkgs -b nixpkgs-unstable",
" niv add my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip"
]
]

-- parse a github shortcut of the form "owner/repo"
Expand Down
8 changes: 5 additions & 3 deletions src/Niv/Local/Cmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ describeLocal =
Opts.progDesc "Add a local dependency. Experimental.",
Opts.headerDoc $
Just $
"Examples:"
Opts.<$$> ""
Opts.<$$> " niv add local ./foo/bar"
Opts.vcat
[ "Examples:",
"",
" niv add local ./foo/bar"
]
]

0 comments on commit a1c35f7

Please sign in to comment.