mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
added -h --help option to display help
This commit is contained in:
@ -14,6 +14,7 @@ class CmdLineParser {
|
||||
int detector_id() const { return detector_id_; };
|
||||
int n_arguments() const { return arguments_.size(); }
|
||||
const std::string &command() const { return command_; }
|
||||
bool isHelp() const{return help_;}
|
||||
void setCommand(std::string cmd){command_ = cmd;}
|
||||
const std::string &executable() const { return executable_; }
|
||||
const std::vector<std::string> &arguments() const { return arguments_; };
|
||||
@ -23,6 +24,7 @@ class CmdLineParser {
|
||||
void DecodeIdAndPosition(const char *c);
|
||||
int multi_id_ = 0;
|
||||
int detector_id_ = -1;
|
||||
bool help_{false};
|
||||
std::string command_;
|
||||
std::string executable_;
|
||||
std::vector<std::string> arguments_;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "logger.h"
|
||||
#include "slsDetectorCommand.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
namespace sls {
|
||||
@ -20,7 +21,8 @@ template <typename T> class CmdProxy {
|
||||
|
||||
std::string Call(const std::string &command,
|
||||
const std::vector<std::string> &arguments,
|
||||
int detector_id) {
|
||||
int detector_id,
|
||||
int action=-1) {
|
||||
cmd = command;
|
||||
args = arguments;
|
||||
det_id = detector_id;
|
||||
@ -29,7 +31,7 @@ template <typename T> class CmdProxy {
|
||||
|
||||
auto it = functions.find(cmd);
|
||||
if (it != functions.end()) {
|
||||
std::cout << ((*this).*(it->second))();
|
||||
std::cout << ((*this).*(it->second))(action);
|
||||
return {};
|
||||
} else {
|
||||
return cmd;
|
||||
@ -57,7 +59,7 @@ template <typename T> class CmdProxy {
|
||||
std::vector<std::string> args;
|
||||
int det_id{-1};
|
||||
|
||||
using FunctionMap = std::map<std::string, std::string (CmdProxy::*)()>;
|
||||
using FunctionMap = std::map<std::string, std::string (CmdProxy::*)(int)>;
|
||||
using StringMap = std::map<std::string, std::string>;
|
||||
|
||||
// Initialize maps for translating name and function
|
||||
@ -91,7 +93,10 @@ template <typename T> class CmdProxy {
|
||||
|
||||
// Mapped functions
|
||||
|
||||
std::string ListCommands() {
|
||||
std::string ListCommands(int action) {
|
||||
if (action==slsDetectorDefs::HELP_ACTION)
|
||||
return "list - lists all available commands, list deprecated - list deprecated commands\n";
|
||||
|
||||
if (args.size() == 0) {
|
||||
auto commands = slsDetectorCommand(nullptr).getAllCommands();
|
||||
for (const auto &it : functions)
|
||||
|
Reference in New Issue
Block a user