getArgs

Computation getArgs returns a list of the program's command line arguments (not including the program name).
Computation getArgs returns a list of the program's command line arguments (not including the program name), as ByteStrings. Unlike getArgs, this function does no Unicode decoding of the arguments; you get the exact bytes that were passed to the program by the OS. To interpret the arguments as text, some Unicode decoding should be applied.
Computation getArgs returns a list of the program's command line arguments (not including the program name), as PosixStrings. Unlike getArgs, this function does no Unicode decoding of the arguments; you get the exact bytes that were passed to the program by the OS. To interpret the arguments as text, some Unicode decoding should be applied.
Lifted getArgs.
Lifted version of getArgs.
Returns a list of the program's command line arguments (not including the program name).
Get the arguments from the terminal command
Parse the CLI arguments with CmdArgs.
Parse command line arguments. The arguments are taken from a call to getArgs and parsed. Any error is thrown as a ArgError exception. The result is a value from which the information in the command line can be extracted by the arg..., reqarg... and optarg... functions. The header is used only by the deprecated usage_info function. If you don't use it, you don't need to specify a header. Just pass an empty string. Named arguments (like -x or --arg) and direct arguments may occur in any order. See usage_info, make_usage_info, print_usage_info.
Like getArgs, but can also read arguments supplied via response files. For example, consider a program foo:
main :: IO ()
main = do
args <- getArgsWithResponseFiles
putStrLn (show args)
And a response file args.txt:
--one 1
--'two' 2
--"three" 3
Then the result of invoking foo with args.txt is:
> ./foo @args.txt
["--one","1","--two","2","--three","3"]
Convenience action: Initialize GLUT, returning the program name and any non-GLUT command line arguments.
Treat the String value, if any, of the given argument as a file handle and try to open it as requested. If not present, substitute the appropriate one of stdin or stdout as indicated by IOMode.
  • Deprecated Return the String value, if any, of the given argument.
Parse the specified command line. Any error is returned as Left argerror. In case of success, the result is returned as Right res. From the result, the information in the command line can be extracted by the arg..., reqarg... and optarg... functions. The header is used only by the deprecated usage_info function. If you don't use it, you don't need to specify a header. Just pass an empty string. Named arguments (like -x or --arg) and direct arguments may occur in any order. See usage_info, make_usage_info, print_usage_info.
Parse command line arguments. The arguments are taken from a call to getArgs and parsed. Any error is thrown as a ArgError exception. The result is a value from which the information in the command line can be extracted by the arg..., reqarg... and optarg... functions. The header is used only by the deprecated usage_info function. If you don't use it, you don't need to specify a header. Just pass an empty string. All arguments after the first direct argument are regarded as direct arguments. This means that argument names introduced by - or -- no longer take effect. See usage_info, make_usage_info, print_usage_info.
Parse the specified command line. Any error is returned as Left argerror. In case of success, the result is returned as Right res. From the result, the information in the command line can be extracted by the arg..., reqarg... and optarg... functions. The header is used only by the deprecated usage_info function. If you don't use it, you don't need to specify a header. Just pass an empty string. All arguments after the first direct argument are regarded as direct arguments. This means that argument names introduced by - or -- no longer take effect. See usage_info, make_usage_info, print_usage_info.
getargs as a pure function, instead of an IO action. This allows to make evaluated command line arguments global values. This calls getargs to parse the command line arguments. GHC.IO.unsafePerformIO is used to take the result out of the IO monad.
unsafe_getargs header descs = GHC.IO.unsafePerformIO $ getargs "" descs
The getargs action is performed on demand, when the parse result is evaluated. It may result in an ArgError being thrown. In order to avoid this happening at unexpected times, the main function should, start with the line seq args (return ()), where args is the result of unsafe_getargs,. This will trigger any command line argument errors at the beginning of the program. (See section 6.2 of the Hakell Report for the definition of seq). The header is used only by the deprecated usage_info function. If you don't use it, you don't need to specify a header. Just pass an empty string. A typical use of unsafe_getargs looks like this:
descs = [ d_myflag, ... ]

d_myflag = argdesc [ ... ]

args = unsafe_getargs "" descs
myflag = arg_switch args d_myflag

main = mainwrapper $ do
seq args (return ())
...
See getargs, unsafe_getargs_ordered.
getargs_ordered as a pure function, instead of an IO action. This is exactly like unsafe_getargs, but using getargs_ordered instead of getargs. The header is used only by the deprecated usage_info function. If you don't use it, you don't need to specify a header. Just pass an empty string. The definition is:
unsafe_getargs_ordered = GHC.IO.unsafePerformIO $ getargs_ordered "" descs
See unsafe_getargs, usage_info, make_usage_info, print_usage_info.