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

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.CodeGen.Backends.GenericPython.Options

Description

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

Synopsis

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

# 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.

When the statement is being executed, the argument (if any) will be stored in the variable `optarg`.

Constructors

Option |

Fields

- optionLongName :: Text
- optionShortName :: Maybe Char
- optionArgument :: OptionArgument
- optionAction :: [PyStmt]

data OptionArgument Source #

Whether an option accepts an argument.

Constructors

NoArgument |
RequiredArgument String |
OptionalArgument |

generateOptionParser :: [Option] -> [PyStmt] Source #

Generate option parsing code that accepts the given command line options. Will read from `sys.argv`.

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