Boost Program Options

Use Case

Boost Program Options library usage to access user input to the program

Session 1:

  • Updated main.cpp to use program options library
  • Captures user inputs

Libraries Used

Session 1

Video explanation of the code

C++-Boost-Program-Options

Program options input screen

root@efa32de8e392:/workspace/backend-cpp# LD_LIBRARY_PATH=/usr/src/redis-plus-plus-modules/lib:/workspace/backend-cpp/boost_1_81_0//stage/lib ./dist/backend-cpp --help
[2023-03-11 05:19:35.676734] [0x00007fe9039040c0] [info]    Allowed options:

Generic options:
  -v [ --version ]                      print version string
  --help                                produce help message
  -c [ --config ] arg (=app.cfg)        name of a file of a configuration.
  -s [ --sub-program-name ] arg (=ws-vendor)
                                        Module name to run. Options:
                                        ws-vendor|redis-uploader|webserver.

Configuration:
  --ws-vendor-hostname arg              websocket vendor hostname
  --ws-vendor-port arg                  websocket vendor port
  --ws-vendor-greeting-str arg          websocket vendor greeting string
  --ws-vendor-endpoint arg              websocket vendor endpoint
  --ws-vendor-no-threads arg            websocket vendor no of threads
  --redis-topics arg                    comma separated list of redis topics
  --webserver-hostname arg              webserver hostname or ip address to run
                                        on
  --webserver-port arg                  webserver port
  --webserver-root-dir arg              webserver root dir
  --webserver-no-threads arg            webserver no of threads
  --webserver-topics arg                comma separated list of topics
  --log-level arg                       log level

Source Code

comments powered by Disqus