mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-03 08:30:41 +02:00
Dev/document autocomplete (#1004)
* fixed the gendoc to reflect the new parser, updated documentation to include info about autocomplete in the command line part, error in createing docs * fixed list deprecated, fixed command help (to show properly on a html, fixed other help warnings * minor indents --------- Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
This commit is contained in:
parent
0b9fd0664e
commit
6fcdba56a4
@ -8,7 +8,7 @@ Commands can be used either with sls_detector_get or sls_detector_put
|
||||
|
||||
.. code-block::
|
||||
|
||||
sls_detector_get vrf
|
||||
sls_detector_get exptime
|
||||
|
||||
Help
|
||||
--------
|
||||
@ -24,6 +24,16 @@ Help
|
||||
# get help for a particular command
|
||||
sls_detector_get -h fpath
|
||||
sls_detector_help fpath
|
||||
|
||||
# list of deprecated commands
|
||||
list deprecated
|
||||
|
||||
# autocompletion
|
||||
# bash_autocomplete.sh or zsh_autocomplete.sh must be sourced from the
|
||||
# main package folder to enable auto completion of commands and arguments
|
||||
# for the command line on that shell.
|
||||
source bash_autocomplete.sh
|
||||
|
||||
|
||||
|
||||
Commands
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "CmdProxy.h"
|
||||
#include "Caller.h"
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
@ -37,8 +37,8 @@ int main() {
|
||||
|
||||
std::cout << "Generating command line documentation!\n";
|
||||
|
||||
sls::CmdProxy proxy(nullptr);
|
||||
auto commands = proxy.GetProxyCommands();
|
||||
sls::Caller caller(nullptr);
|
||||
auto commands = caller.getAllCommands();
|
||||
|
||||
std::ofstream fs("commands.rst");
|
||||
fs << ".. glossary::\n";
|
||||
@ -46,7 +46,7 @@ int main() {
|
||||
for (const auto &cmd : commands) {
|
||||
std::ostringstream os;
|
||||
std::cout << cmd << '\n';
|
||||
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
||||
caller.call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
|
||||
|
||||
auto tmp = os.str().erase(0, cmd.size());
|
||||
auto usage = tmp.substr(0, tmp.find_first_of('\n'));
|
||||
@ -57,7 +57,7 @@ int main() {
|
||||
|
||||
std::ofstream fs2("deprecated.csv");
|
||||
fs2 << "Old, New\n";
|
||||
auto cmds = proxy.GetDeprecatedCommands();
|
||||
auto cmds = caller.GetDeprecatedCommands();
|
||||
for (auto it : cmds) {
|
||||
fs2 << it.first << ", " << it.second << '\n';
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ ZMQ: Json Header Format
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| detType | Detector type enum |
|
||||
| detSpec3 | See :ref:`Detector enum<Detector Enum>` |
|
||||
| detSpec3 | See :ref:`Detector enum<detector enum>` |
|
||||
| | [From detector udp header] |
|
||||
+--------------+----------------------------------------------+
|
||||
| version | Detector header version. At 2 |
|
||||
|
@ -63,6 +63,8 @@ Description
|
||||
* **version**: current version of the detector header (0x2).
|
||||
|
||||
|
||||
.. _detector enum:
|
||||
|
||||
Detector Enum
|
||||
--------------
|
||||
|
||||
|
@ -55,6 +55,7 @@ class Caller {
|
||||
}
|
||||
|
||||
std::vector<std::string> getAllCommands();
|
||||
std::map<std::string, std::string> GetDeprecatedCommands();
|
||||
std::string list(int action);
|
||||
|
||||
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1)
|
||||
|
@ -793,7 +793,7 @@ selinterface:
|
||||
input_types: [ bool ]
|
||||
|
||||
udp_firstdst:
|
||||
help: "\n[0 - 31 (or number of udp destinations)]\n\t[Jungfrau][Moench][Gotthard2]\n[0-63]\n\t[Mythen3]\n\n\t One can set which is the first destination that the detector will stream images out from in a round robin fashion. The entry must not have been empty. Default: 0"
|
||||
help: "\n\t[0 - N]\n\twhere N is the max number of udp destinations - 1.\n\t[Jungfrau][Moench][Gotthard2] Max number of udp destinations is 32.\n\t[Mythen3] Max number of udp destination is 64.\n\t One can set which is the first destination that the detector will stream images out from in a round robin fashion. The entry must not have been empty. Default: 0"
|
||||
inherit_actions: INTEGER_COMMAND_VEC_ID
|
||||
actions:
|
||||
GET:
|
||||
@ -1074,7 +1074,7 @@ interruptsubframe:
|
||||
input_types: [ bool ]
|
||||
|
||||
activate:
|
||||
help: "[0, 1] \n\t[Eiger] 1 is default. 0 deactivates readout and does not send data."
|
||||
help: "[0, 1]\n\t[Eiger] 1 is default. 0 deactivates readout and does not send data."
|
||||
inherit_actions: INTEGER_COMMAND_VEC_ID
|
||||
actions:
|
||||
GET:
|
||||
@ -1779,7 +1779,7 @@ udp_validate:
|
||||
|
||||
clearroi:
|
||||
inherit_actions: EXECUTE_SET_COMMAND
|
||||
help: "[Gotthard] Resets Region of interest in detector. All channels enabled. Default is all channels enabled."
|
||||
help: "\n\t[Gotthard] Resets Region of interest in detector. All channels enabled. Default is all channels enabled."
|
||||
actions:
|
||||
PUT:
|
||||
function: clearROI
|
||||
@ -2034,7 +2034,7 @@ framecounter:
|
||||
################# GET_COMMAND_HEX ############################
|
||||
serialnumber:
|
||||
inherit_actions: GET_COMMAND
|
||||
help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\nSerial number of detector."
|
||||
help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\n\tSerial number of detector."
|
||||
actions:
|
||||
GET:
|
||||
function: getSerialNumber
|
||||
@ -3429,7 +3429,7 @@ udp_dstlist:
|
||||
output: [ ToString(args) ]
|
||||
|
||||
txdelay:
|
||||
help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.Sets up \n\t\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n\t\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n\t\t[Eiger] txdelay_frame to (2 *num_modules * n_delay) \n\t\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay) \nfor every module."
|
||||
help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for all modules in the detector using the step size provided.Sets up \n\t[Eiger] txdelay_left to (2 * mod_index * n_delay), \n\t[Eiger] txdelay_right to ((2 * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 *num_modules * n_delay)\n\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay) for every module."
|
||||
actions:
|
||||
GET:
|
||||
argc: 0
|
||||
@ -3963,7 +3963,7 @@ patloop:
|
||||
output: [level,"' '" , "'['" , "ToStringHex(start, 4)" , '", "' , "ToStringHex(stop, 4)", "']'" ]
|
||||
|
||||
patloop0:
|
||||
help: "Deprecated command. Use patloop."
|
||||
help: "\n\tDeprecated command. Use patloop."
|
||||
inherit_actions: patloop
|
||||
actions:
|
||||
GET:
|
||||
@ -4010,7 +4010,7 @@ patnloop:
|
||||
output: [ level,"' '" , nloops ]
|
||||
|
||||
patnloop0:
|
||||
help: "Deprecated command. Use patnloop."
|
||||
help: "\n\tDeprecated command. Use patnloop."
|
||||
inherit_actions: patnloop
|
||||
actions:
|
||||
GET:
|
||||
@ -4056,7 +4056,7 @@ patwait:
|
||||
output: [level,"' '" , "ToStringHex(addr, 4)" ]
|
||||
|
||||
patwait0:
|
||||
help: "Deprecated command. Use patwait."
|
||||
help: "\n\tDeprecated command. Use patwait."
|
||||
inherit_actions: patwait
|
||||
actions:
|
||||
GET:
|
||||
@ -4102,7 +4102,7 @@ patwaittime:
|
||||
output: [level,"' '" , "waittime" ]
|
||||
|
||||
patwaittime0:
|
||||
help: "Deprecated command. Use patwaittime."
|
||||
help: "\n\tDeprecated command. Use patwaittime."
|
||||
inherit_actions: patwaittime
|
||||
actions:
|
||||
GET:
|
||||
|
@ -67,8 +67,7 @@ activate:
|
||||
store_result_in_t: false
|
||||
command_name: activate
|
||||
function_alias: activate
|
||||
help: "[0, 1] \n\t[Eiger] 1 is default. 0 deactivates readout and does not send\
|
||||
\ data."
|
||||
help: "[0, 1]\n\t[Eiger] 1 is default. 0 deactivates readout and does not send data."
|
||||
infer_action: true
|
||||
template: true
|
||||
adcclk:
|
||||
@ -1206,8 +1205,8 @@ clearroi:
|
||||
store_result_in_t: false
|
||||
command_name: clearroi
|
||||
function_alias: clearroi
|
||||
help: '[Gotthard] Resets Region of interest in detector. All channels enabled. Default
|
||||
is all channels enabled.'
|
||||
help: "\n\t[Gotthard] Resets Region of interest in detector. All channels enabled.\
|
||||
\ Default is all channels enabled."
|
||||
infer_action: true
|
||||
template: true
|
||||
clientversion:
|
||||
@ -6078,7 +6077,7 @@ patloop0:
|
||||
store_result_in_t: false
|
||||
command_name: patloop0
|
||||
function_alias: patloop0
|
||||
help: Deprecated command. Use patloop.
|
||||
help: "\n\tDeprecated command. Use patloop."
|
||||
infer_action: true
|
||||
patloop1:
|
||||
actions:
|
||||
@ -6147,7 +6146,7 @@ patloop1:
|
||||
store_result_in_t: false
|
||||
command_name: patloop1
|
||||
function_alias: patloop1
|
||||
help: Deprecated command. Use patloop.
|
||||
help: "\n\tDeprecated command. Use patloop."
|
||||
infer_action: true
|
||||
patloop2:
|
||||
actions:
|
||||
@ -6216,7 +6215,7 @@ patloop2:
|
||||
store_result_in_t: false
|
||||
command_name: patloop2
|
||||
function_alias: patloop2
|
||||
help: Deprecated command. Use patloop.
|
||||
help: "\n\tDeprecated command. Use patloop."
|
||||
infer_action: true
|
||||
patmask:
|
||||
actions:
|
||||
@ -6377,7 +6376,7 @@ patnloop0:
|
||||
store_result_in_t: false
|
||||
command_name: patnloop0
|
||||
function_alias: patnloop0
|
||||
help: Deprecated command. Use patnloop.
|
||||
help: "\n\tDeprecated command. Use patnloop."
|
||||
infer_action: true
|
||||
patnloop1:
|
||||
actions:
|
||||
@ -6435,7 +6434,7 @@ patnloop1:
|
||||
store_result_in_t: false
|
||||
command_name: patnloop1
|
||||
function_alias: patnloop1
|
||||
help: Deprecated command. Use patnloop.
|
||||
help: "\n\tDeprecated command. Use patnloop."
|
||||
infer_action: true
|
||||
patnloop2:
|
||||
actions:
|
||||
@ -6493,7 +6492,7 @@ patnloop2:
|
||||
store_result_in_t: false
|
||||
command_name: patnloop2
|
||||
function_alias: patnloop2
|
||||
help: Deprecated command. Use patnloop.
|
||||
help: "\n\tDeprecated command. Use patnloop."
|
||||
infer_action: true
|
||||
patsetbit:
|
||||
actions:
|
||||
@ -6700,7 +6699,7 @@ patwait0:
|
||||
store_result_in_t: false
|
||||
command_name: patwait0
|
||||
function_alias: patwait0
|
||||
help: Deprecated command. Use patwait.
|
||||
help: "\n\tDeprecated command. Use patwait."
|
||||
infer_action: true
|
||||
patwait1:
|
||||
actions:
|
||||
@ -6758,7 +6757,7 @@ patwait1:
|
||||
store_result_in_t: false
|
||||
command_name: patwait1
|
||||
function_alias: patwait1
|
||||
help: Deprecated command. Use patwait.
|
||||
help: "\n\tDeprecated command. Use patwait."
|
||||
infer_action: true
|
||||
patwait2:
|
||||
actions:
|
||||
@ -6816,7 +6815,7 @@ patwait2:
|
||||
store_result_in_t: false
|
||||
command_name: patwait2
|
||||
function_alias: patwait2
|
||||
help: Deprecated command. Use patwait.
|
||||
help: "\n\tDeprecated command. Use patwait."
|
||||
infer_action: true
|
||||
patwaittime:
|
||||
actions:
|
||||
@ -6937,7 +6936,7 @@ patwaittime0:
|
||||
store_result_in_t: false
|
||||
command_name: patwaittime0
|
||||
function_alias: patwaittime0
|
||||
help: Deprecated command. Use patwaittime.
|
||||
help: "\n\tDeprecated command. Use patwaittime."
|
||||
infer_action: true
|
||||
patwaittime1:
|
||||
actions:
|
||||
@ -6995,7 +6994,7 @@ patwaittime1:
|
||||
store_result_in_t: false
|
||||
command_name: patwaittime1
|
||||
function_alias: patwaittime1
|
||||
help: Deprecated command. Use patwaittime.
|
||||
help: "\n\tDeprecated command. Use patwaittime."
|
||||
infer_action: true
|
||||
patwaittime2:
|
||||
actions:
|
||||
@ -7053,7 +7052,7 @@ patwaittime2:
|
||||
store_result_in_t: false
|
||||
command_name: patwaittime2
|
||||
function_alias: patwaittime2
|
||||
help: Deprecated command. Use patwaittime.
|
||||
help: "\n\tDeprecated command. Use patwaittime."
|
||||
infer_action: true
|
||||
patword:
|
||||
actions:
|
||||
@ -9754,7 +9753,7 @@ serialnumber:
|
||||
store_result_in_t: true
|
||||
command_name: serialnumber
|
||||
function_alias: serialnumber
|
||||
help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\nSerial number\
|
||||
help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb]\n\tSerial number\
|
||||
\ of detector."
|
||||
infer_action: true
|
||||
template: true
|
||||
@ -11913,11 +11912,11 @@ txdelay:
|
||||
command_name: txdelay
|
||||
function_alias: txdelay
|
||||
help: "[n_delay]\n\t[Eiger][Jungfrau][Moench][Mythen3] Set transmission delay for\
|
||||
\ all modules in the detector using the step size provided.Sets up \n\t\t[Eiger]\
|
||||
\ txdelay_left to (2 * mod_index * n_delay), \n\t\t[Eiger] txdelay_right to ((2\
|
||||
\ * mod_index + 1) * n_delay) and \n\t\t[Eiger] txdelay_frame to (2 *num_modules\
|
||||
\ * n_delay) \n\t\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules\
|
||||
\ * n_delay) \nfor every module."
|
||||
\ all modules in the detector using the step size provided.Sets up \n\t[Eiger]\
|
||||
\ txdelay_left to (2 * mod_index * n_delay), \n\t[Eiger] txdelay_right to ((2\
|
||||
\ * mod_index + 1) * n_delay) and \n\t[Eiger] txdelay_frame to (2 *num_modules\
|
||||
\ * n_delay)\n\t[Jungfrau][Moench][Mythen3] txdelay_frame to (num_modules * n_delay)\
|
||||
\ for every module."
|
||||
infer_action: true
|
||||
txdelay_frame:
|
||||
actions:
|
||||
@ -12417,10 +12416,11 @@ udp_firstdst:
|
||||
store_result_in_t: false
|
||||
command_name: udp_firstdst
|
||||
function_alias: udp_firstdst
|
||||
help: "\n[0 - 31 (or number of udp destinations)]\n\t[Jungfrau][Moench][Gotthard2]\n\
|
||||
[0-63]\n\t[Mythen3]\n\n\t One can set which is the first destination that the\
|
||||
\ detector will stream images out from in a round robin fashion. The entry must\
|
||||
\ not have been empty. Default: 0"
|
||||
help: "\n\t[0 - N]\n\twhere N is the max number of udp destinations - 1.\n\t[Jungfrau][Moench][Gotthard2]\
|
||||
\ Max number of udp destinations is 32.\n\t[Mythen3] Max number of udp destination\
|
||||
\ is 64.\n\t One can set which is the first destination that the detector will\
|
||||
\ stream images out from in a round robin fashion. The entry must not have been\
|
||||
\ empty. Default: 0"
|
||||
infer_action: true
|
||||
template: true
|
||||
udp_numdst:
|
||||
|
@ -60,7 +60,6 @@ def generate(
|
||||
if command["help"].startswith('code:'):
|
||||
codegen.write_line(command["help"].strip('code:'))
|
||||
else:
|
||||
codegen.write_line(f'os << "Command: {command_name}" << std::endl;')
|
||||
codegen.write_line(f'os << R"V0G0N({command["help"]} )V0G0N" << std::endl;')
|
||||
codegen.write_line('return os.str();')
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -55,6 +55,7 @@ class Caller {
|
||||
}
|
||||
|
||||
std::vector<std::string> getAllCommands();
|
||||
std::map<std::string, std::string> GetDeprecatedCommands();
|
||||
std::string list(int action);
|
||||
|
||||
std::string acquire(int action);
|
||||
|
@ -16,6 +16,10 @@ std::vector<std::string> Caller::getAllCommands() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> Caller::GetDeprecatedCommands() {
|
||||
return deprecated_functions;
|
||||
}
|
||||
|
||||
void Caller::call(const std::string &command,
|
||||
const std::vector<std::string> &arguments, int detector_id,
|
||||
int action, std::ostream &os, int receiver_id) {
|
||||
@ -63,12 +67,35 @@ bool Caller::ReplaceIfDeprecated(std::string &command) {
|
||||
}
|
||||
|
||||
std::string Caller::list(int action) {
|
||||
std::string ret = "free\n";
|
||||
for (auto &f : functions) {
|
||||
ret += f.first + "\n";
|
||||
if (action == defs::HELP_ACTION) {
|
||||
return "[deprecated(optional)]\n\tlists all available commands, list "
|
||||
"deprecated - list deprecated commands\n";
|
||||
}
|
||||
if (args.empty()) {
|
||||
std::string ret = "free\n";
|
||||
for (auto &f : functions) {
|
||||
ret += f.first + "\n";
|
||||
}
|
||||
return ret;
|
||||
} else if (args.size() == 1) {
|
||||
if (args[0] == "deprecated") {
|
||||
std::ostringstream os;
|
||||
os << "The following " << deprecated_functions.size()
|
||||
<< " commands are deprecated\n";
|
||||
const size_t field_width = 20;
|
||||
for (const auto &it : deprecated_functions) {
|
||||
os << std::right << std::setw(field_width) << it.first << " -> "
|
||||
<< it.second << '\n';
|
||||
}
|
||||
return os.str();
|
||||
} else {
|
||||
throw RuntimeError(
|
||||
"Could not decode argument. Possible options: deprecated");
|
||||
}
|
||||
} else {
|
||||
WrongNumberOfParameters(0);
|
||||
return "";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
|
1
zsh_autocomplete.sh
Symbolic link
1
zsh_autocomplete.sh
Symbolic link
@ -0,0 +1 @@
|
||||
slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh
|
Loading…
x
Reference in New Issue
Block a user