@@ -30,14 +30,17 @@ import Security.Advisories.Generate.HTML
3030import qualified Command.Reserve
3131
3232main :: IO ()
33- main = join $ execParser cliOpts
33+ main = join $
34+ customExecParser
35+ (prefs showHelpOnEmpty)
36+ cliOpts
3437
3538cliOpts :: ParserInfo (IO () )
3639cliOpts = info (commandsParser <**> helper) (fullDesc <> header " Haskell Advisories tools" )
3740 where
3841 commandsParser :: Parser (IO () )
3942 commandsParser =
40- subparser
43+ hsubparser
4144 ( command " check" (info commandCheck (progDesc " Syntax check a single advisory" ))
4245 <> command " reserve" (info commandReserve (progDesc " Reserve an HSEC ID" ))
4346 <> command " osv" (info commandOsv (progDesc " Convert a single advisory to OSV" ))
@@ -70,13 +73,11 @@ commandReserve =
7073 ( long " commit"
7174 <> help " Commit the reservation file"
7275 )
73- <**> helper
7476
7577commandCheck :: Parser (IO () )
7678commandCheck =
7779 withAdvisory go
7880 <$> optional (argument str (metavar " FILE" ))
79- <**> helper
8081 where
8182 go mPath advisory = do
8283 for_ mPath $ \ path -> do
@@ -89,7 +90,6 @@ commandOsv :: Parser (IO ())
8990commandOsv =
9091 withAdvisory go
9192 <$> optional (argument str (metavar " FILE" ))
92- <**> helper
9393 where
9494 go _ adv = do
9595 L. putStr (Data.Aeson. encode (OSV. convert adv))
@@ -99,22 +99,19 @@ commandRender :: Parser (IO ())
9999commandRender =
100100 withAdvisory (\ _ -> T. putStrLn . advisoryHtml)
101101 <$> optional (argument str (metavar " FILE" ))
102- <**> helper
103102
104103commandQuery :: Parser (IO () )
105104commandQuery =
106105 subparser
107106 ( command " is-affected" (info isAffected (progDesc " Check if a package/version range is marked vulnerable" ))
108107 )
109- <**> helper
110108 where
111109 isAffected :: Parser (IO () )
112110 isAffected =
113111 go
114112 <$> argument str (metavar " PACKAGE" )
115113 <*> optional (option versionRangeReader (metavar " VERSION-RANGE" <> short ' v' <> long " version-range" ))
116114 <*> optional (option str (metavar " ADVISORIES-PATH" <> short ' p' <> long " advisories-path" ))
117- <**> helper
118115 where go :: T. Text -> Maybe VersionRange -> Maybe FilePath -> IO ()
119116 go packageName versionRange advisoriesPath = do
120117 let versionRange' = fromMaybe anyVersion versionRange
@@ -140,7 +137,6 @@ commandGenerateIndex =
140137 )
141138 <$> argument str (metavar " SOURCE-DIR" )
142139 <*> argument str (metavar " DESTINATION-DIR" )
143- <**> helper
144140
145141commandHelp :: Parser (IO () )
146142commandHelp =
@@ -149,7 +145,6 @@ commandHelp =
149145 in void $ handleParseResult $ execParserPure defaultPrefs cliOpts args
150146 )
151147 <$> optional (argument str (metavar " COMMAND" ))
152- <**> helper
153148
154149versionRangeReader :: ReadM VersionRange
155150versionRangeReader = eitherReader eitherParsec
0 commit comments