... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   ["$" documentation]
   [control
    ["[0]" io]]
   [data
    [collection
     ["[0]" list]]]]]
 ["[0]" \\projection]
 [\\library
  ["[0]" /]])

(the \\projection
  (List $.Documentation)
  (list ($.module \\projection._
                  "")
        ($.definition (\\projection.Projection it)
          "A command-line interface projection.")

        ($.definition \\projection.value
          "Executes the projection and verifies that all inputs are processed."
          ($.example (' (value projection inputs))))

        ($.definition \\projection.any
          "Just returns the next input without applying any logic.")

        ($.definition \\projection.parse
          "Parses the next input with a parsing function."
          ($.example (' (parse projection))))

        ($.definition \\projection.this
          "Checks that a token is in the inputs."
          ($.example (' (this reference))))

        ($.definition \\projection.somewhere
          "Given a projection, tries to parse it somewhere in the inputs (i.e. not necessarily parsing the immediate inputs)."
          ($.example (' (somewhere cli))))

        ($.definition \\projection.end
          "Ensures there are no more inputs.")

        ($.definition \\projection.named
          "Parses a named parameter and yields its value."
          ($.example (' (named name value))))

        ($.definition \\projection.parameter
          "Parses a parameter that can have either a short or a long name."
          ($.example (' (parameter [short long] value))))
        ))

(the .public documentation
  (List $.Documentation)
  (list.partial ($.module /._
                          "")

                ($.definition /.program
                  "Defines the entry-point to a program (similar to the 'main' function/method in other programming languages)."

                  ($.comment "Can take a list of all the input parameters to the program.")
                  ($.example (' (the _
                                  (program all_arguments
                                    (do io.monad
                                      [foo (initialize program)]
                                      (do_something_with all_arguments))))))

                  ($.comment "Can also parse them using CLI projections from the library/lux/control/projection/cli module.")
                  ($.example (' (the _
                                  (program [config configuration_projection]
                                    (do io.monad
                                      [data (initialize program with config)]
                                      (do_something_with data)))))))

                ..\\projection
                ))
