// file      : bbot/worker.cli
// license   : MIT; see accompanying LICENSE file

include <bbot/common.cli>;

"\section=1"
"\name=bbot-worker"
"\summary=build bot worker"

namespace bbot
{
  {
    "<options> <module> <cfg-var>",

    "
    \h|SYNOPSIS|

    \c{\b{bbot-worker --help}\n
       \b{bbot-worker --version}\n
       \b{bbot-worker --bootstrap} [<options>]\n
       \b{bbot-worker --startup} [<options>]\n
       \b{bbot-worker} [<options>] <module>... <cfg-var>...}

    \h|DESCRIPTION|

    \cb{bbot-worker} @@ TODO.

    If the \cb{--bootstrap} mode option is specified, then the worker performs
    the initial machine bootstrap and writes the bootstrap result manifest to
    \c{stdout}. If the \cb{--startup} mode option is specified, then the
    worker performs the environment setup and then re-executes in the build
    mode. If neither of the mode options is specified, then the worker
    proceeds to performing the build task.
    "
  }

  class worker_options
  {
    "\h|OPTIONS|"

    //
    // NOTE: when adding new options, consider whether they should be
    //       propagated from startup to build.
    //

    bool --help {"Print usage information and exit."}
    bool --version {"Print version and exit."}

    uint16_t --verbose = 1
    {
      "<level>",
      "Set the diagnostics verbosity to <level> between 0 and 6 with level 1
       being the default."
    }

    bool --bootstrap
    {
      "Perform the inital machine bootstrap insteading of building."
    }

    bool --startup
    {
      "Perform the environment setup and then re-execute for building."
    }

    bool --systemd-daemon
    {
      "Run as a simple systemd daemon."
    }

    dir_path --build
    {
      "<dir>",
      "The directory to perform the build in. If not specified, then the
       current working directory is used."
    }

    dir_path --environments
    {
      "<dir>",
      "The directory containing the environment setup executables. If not
       specified, then the user's home directory is used."
    }

    path --env-script
    {
      "<path>",
      "The environment setup executable path. This option is normally passed
       by the worker running in the startup mode to the worker executed in the
       build mode."
    }

    string --env-target
    {
      "<target>",
      "The environment setup executable target argument. This option is
       normally passed by the worker running in the startup mode to the worker
       executed in the build mode."
    }

    // Testing options.
    //
    string --tftp-host = "196.254.111.222"
    {
      "<addr>",
      "The TFTP host address and, optionally, port to use to download the
       build task and to upload the build result. By default the link-local
       address 196.254.111.222 with the standard TFTP port (69) is used."
    }
  };

  "
  \h|EXIT STATUS|

  Non-zero exit status is returned in case of an error. In the build mode,
  exit code 2 is used to signal abnormal termination where the worker
  uploaded the result manifest itself.
  "
}
