cloud-seeder-0.1.0.0: A tool for interacting with AWS CloudFormation

Safe HaskellNone
LanguageHaskell2010

Network.CloudSeeder.CommandLine

Description

This module implements command-line parsing for cloud-seeder. The core command-line interface, from the user’s point of view, is simple: there are a set of subcommands (such as “provision”) that take various positional arguments and flags. Internally, however, the parsing is a little more complex, and this is because we want to use the user’s deployment configuration to generate a set of options that may be supplied.

For example, if the user specifies the following configuration:

deployment "foo" $ do
  flag SomeParam

…then we want to generate a --SomeParam=[PARAM] option. Not only that, we want to make it optional or required based on whether or not there is a default value or not.

To accomplish this, we need to collect all the flags from the DSL, then run the command-line parser. If we do that, though, we have a new problem! The DSL might need access to the environment, which is a positional argument. This is a circular dependency: we need to parse the environment from the command line in order to execute the DSL, but we need to execute the DSL in order to know which flags to parse from the command line.

To solve this problem, we parse arguments in two phases: first, we parse positional arguments and accept any options (and ignore them). Once we’ve used the information in the positional arguments to evaluate the DSL, we parse the arguments a second time, enhanced with more information.

Synopsis

Documentation

parseArguments :: ParserInfo Command Source #

A parser that corresponds to the first “parsing phase” for the provision subcommand, as described in the module documentation for CommandLine.

parseOptions :: Set ParameterSpec -> ParserInfo (Map Text Text) Source #

A parser that corresponds to the second “parsing phase” for the provision subcommand, as described in the module documentation for CommandLine.