@@ -30,14 +30,17 @@ import Security.Advisories.Generate.HTML
30
30
import qualified Command.Reserve
31
31
32
32
main :: IO ()
33
- main = join $ execParser cliOpts
33
+ main = join $
34
+ customExecParser
35
+ (prefs showHelpOnEmpty)
36
+ cliOpts
34
37
35
38
cliOpts :: ParserInfo (IO () )
36
39
cliOpts = info (commandsParser <**> helper) (fullDesc <> header " Haskell Advisories tools" )
37
40
where
38
41
commandsParser :: Parser (IO () )
39
42
commandsParser =
40
- subparser
43
+ hsubparser
41
44
( command " check" (info commandCheck (progDesc " Syntax check a single advisory" ))
42
45
<> command " reserve" (info commandReserve (progDesc " Reserve an HSEC ID" ))
43
46
<> command " osv" (info commandOsv (progDesc " Convert a single advisory to OSV" ))
@@ -70,13 +73,11 @@ commandReserve =
70
73
( long " commit"
71
74
<> help " Commit the reservation file"
72
75
)
73
- <**> helper
74
76
75
77
commandCheck :: Parser (IO () )
76
78
commandCheck =
77
79
withAdvisory go
78
80
<$> optional (argument str (metavar " FILE" ))
79
- <**> helper
80
81
where
81
82
go mPath advisory = do
82
83
for_ mPath $ \ path -> do
@@ -89,7 +90,6 @@ commandOsv :: Parser (IO ())
89
90
commandOsv =
90
91
withAdvisory go
91
92
<$> optional (argument str (metavar " FILE" ))
92
- <**> helper
93
93
where
94
94
go _ adv = do
95
95
L. putStr (Data.Aeson. encode (OSV. convert adv))
@@ -99,22 +99,19 @@ commandRender :: Parser (IO ())
99
99
commandRender =
100
100
withAdvisory (\ _ -> T. putStrLn . advisoryHtml)
101
101
<$> optional (argument str (metavar " FILE" ))
102
- <**> helper
103
102
104
103
commandQuery :: Parser (IO () )
105
104
commandQuery =
106
105
subparser
107
106
( command " is-affected" (info isAffected (progDesc " Check if a package/version range is marked vulnerable" ))
108
107
)
109
- <**> helper
110
108
where
111
109
isAffected :: Parser (IO () )
112
110
isAffected =
113
111
go
114
112
<$> argument str (metavar " PACKAGE" )
115
113
<*> optional (option versionRangeReader (metavar " VERSION-RANGE" <> short ' v' <> long " version-range" ))
116
114
<*> optional (option str (metavar " ADVISORIES-PATH" <> short ' p' <> long " advisories-path" ))
117
- <**> helper
118
115
where go :: T. Text -> Maybe VersionRange -> Maybe FilePath -> IO ()
119
116
go packageName versionRange advisoriesPath = do
120
117
let versionRange' = fromMaybe anyVersion versionRange
@@ -140,7 +137,6 @@ commandGenerateIndex =
140
137
)
141
138
<$> argument str (metavar " SOURCE-DIR" )
142
139
<*> argument str (metavar " DESTINATION-DIR" )
143
- <**> helper
144
140
145
141
commandHelp :: Parser (IO () )
146
142
commandHelp =
@@ -149,7 +145,6 @@ commandHelp =
149
145
in void $ handleParseResult $ execParserPure defaultPrefs cliOpts args
150
146
)
151
147
<$> optional (argument str (metavar " COMMAND" ))
152
- <**> helper
153
148
154
149
versionRangeReader :: ReadM VersionRange
155
150
versionRangeReader = eitherReader eitherParsec
0 commit comments