-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArguments.hs
40 lines (35 loc) · 991 Bytes
/
Arguments.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Arguments where
import Options.Applicative
import Data.Semigroup ((<>))
import Network.Socket (HostName)
import Scanning (Port, ThreadCount)
data Args = Args
{ host :: HostName
, from :: Port
, to :: Port
, scanTCP :: Bool
, scanUDP :: Bool
, threadsPerCPU :: ThreadCount }
args :: Parser Args
args = Args
<$> argument str (metavar "hostname")
<*> argument auto (metavar "N1")
<*> argument auto (metavar "N2")
<*> switch
( short 't'
<> help "Scan TCP ports" )
<*> switch
( short 'u'
<> help "Scan UDP ports" )
<*> option auto
( long "threads"
<> metavar "N"
<> help "Threads per CPU. High values may cause your machine to halt and catch fire."
<> showDefault
<> value 32 )
opts :: ParserInfo Args
opts = info (args <**> helper)
( fullDesc
<> progDesc "Scan for open ports" )
getArgs :: IO Args
getArgs = execParser opts