futhark-0.25.27: An optimising compiler for a functional, array-oriented language.

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.CodeGen.Backends.GenericC.Options

Description

This module defines a generator for `getopt_long` based command line argument parsing. Each option is associated with arbitrary C code that will perform side effects, usually by setting some global variables.

Synopsis

- data Option = Option {
  - optionLongName :: String
  - optionShortName :: Maybe Char
  - optionArgument :: OptionArgument
  - optionDescription :: String
  - optionAction :: Stm
  }
- data OptionArgument
  - = NoArgument
  - | RequiredArgument String
  - | OptionalArgument
- generateOptionParser :: String -> [Option] -> Func

# Documentation

data Option Source #

Specification if a single command line option. The option must have a long name, and may also have a short name.

In the action, the option argument (if any) is stored as in the `char*`-typed variable `optarg`.

Constructors

Option |

Fields

- optionLongName :: String
- optionShortName :: Maybe Char
- optionArgument :: OptionArgument
- optionDescription :: String
- optionAction :: Stm

data OptionArgument Source #

Whether an option accepts an argument.

Constructors

NoArgument |
RequiredArgument String | The `String` becomes part of the help pretty.
OptionalArgument |

generateOptionParser :: String -> [Option] -> Func Source #

Generate an option parser as a function of the given name, that accepts the given command line options. The result is a function that should be called with `argc` and `argv`. The function returns the number of `argv` elements that have been processed.

If option parsing fails for any reason, the entire process will terminate with error code 1.