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:
- Implement the
ArgsProctrait on an application object, and implement theArgsProc::build_apprt()method. This method should return aSrvAppRtobject, containing the service handler. - Create an instance of the
ArgParser, passing in the service name and a reference to anArgsProcobject. - 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.
- Dereg
Svc - 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§
Functions§
- add_
subcommands - Modify a
clapCommandinstance to accept common service management subcommands. - mk_
inst_ cmd - Create a
clapCommandobject that accepts service registration arguments. - mk_
rm_ cmd - Create a
clapCommandobject that accepts service deregistration arguments. - mk_
run_ cmd - Create a
clapCommandobject that accepts service running arguments.