Module argp

Module argp 

Source
Available on crate feature clap only.
Expand description

Helpers for integrating clap into an application using qsu.

The purpose of the argument parser is to allow a semi-standard command line interface for registering, deregistering and allowing services to run both in the foreground as well as run as actual services. To accomplish this, the argument parser wraps around the runtime. Specifically, this means that if the argument parser is used, the application does not need to launch the runtime explicitly; the argument parser will do this if the appropriate arguments have been passed to it.

Assuming a service handler has been implemented already, a simple use-case for the argument parser in a server application involves:

  1. Implement the ArgsProc trait on an application object, and implement the ArgsProc::build_apprt() method. This method should return a SrvAppRt object, containing the service handler.
  2. Create an instance of the ArgParser, passing in the service name and a reference to an ArgsProc object.
  3. Call ArgParser::proc() to process the command line arguments.

The argument parser will determine whether the caller requested to register/deregister the service, run the server application in foreground mode or as a system service.

§Customization

While the argument parser in qsu is rather opinionated, it does allow for some customization. The names of the subcommands to (de)register or run the server application as a service can be modified by the application. It is possible to register custom subcommands, and the command line parser specification can be modified by the ArgsProc callbacks.

Structs§

ArgParser
High-level argument parser.
DeregSvc
Parsed service deregistration arguments.
RunSvc
Parsed service running arguments.

Enums§

Cmd
Used to differentiate between running without a subcommand, or the install/uninstall or run service subcommands.

Traits§

ArgsProc
Allow application to customise behavior of an ArgParser instance.

Functions§

add_subcommands
Modify a clap Command instance to accept common service management subcommands.
mk_inst_cmd
Create a clap Command object that accepts service registration arguments.
mk_rm_cmd
Create a clap Command object that accepts service deregistration arguments.
mk_run_cmd
Create a clap Command object that accepts service running arguments.