mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 08:29:59 +00:00
Sort operations
This commit is contained in:
parent
d3af9a142c
commit
4a7528d9d3
@ -173,7 +173,7 @@ message PbOperationParameter {
|
||||
|
||||
// The list of parameters supported by an operation
|
||||
message PbOperationParameters {
|
||||
string operation = 1;
|
||||
string name = 1;
|
||||
// Optional short localized description, key is the lower case locale (e.g. en, de)
|
||||
map<string, string> description = 2;
|
||||
repeated PbOperationParameter parameters = 3;
|
||||
|
@ -343,7 +343,7 @@ PbOperationInfo *RascsiResponse::GetOperationInfo(PbResult& result)
|
||||
PbOperationParameter *parameter;
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_operation(PbOperation_Name(ATTACH));
|
||||
parameters->set_name(PbOperation_Name(ATTACH));
|
||||
(*parameters->mutable_description())["en"] = "Attach device, one of the parameters below is required";
|
||||
parameter = parameters->add_parameters();
|
||||
parameter->set_name("name");
|
||||
@ -355,24 +355,42 @@ PbOperationInfo *RascsiResponse::GetOperationInfo(PbResult& result)
|
||||
parameter->set_type("string");
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_operation(PbOperation_Name(DETACH));
|
||||
parameters->set_name(PbOperation_Name(DETACH));
|
||||
(*parameters->mutable_description())["en"] = "Detach device";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_operation(PbOperation_Name(DETACH_ALL));
|
||||
parameters->set_name(PbOperation_Name(DETACH_ALL));
|
||||
(*parameters->mutable_description())["en"] = "Detach all devices";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_operation(PbOperation_Name(START));
|
||||
parameters->set_name(PbOperation_Name(START));
|
||||
(*parameters->mutable_description())["en"] = "Start device";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_operation(PbOperation_Name(STOP));
|
||||
parameters->set_name(PbOperation_Name(STOP));
|
||||
(*parameters->mutable_description())["en"] = "Stop device";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_name(PbOperation_Name(INSERT));
|
||||
(*parameters->mutable_description())["en"] = "Insert medium";
|
||||
parameter = parameters->add_parameters();
|
||||
parameter->set_name("file");
|
||||
(*parameter->mutable_description())["en"] = "Image file name";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_operation(PbOperation_Name(OPERATION_INFO));
|
||||
parameters->set_name(PbOperation_Name(EJECT));
|
||||
(*parameters->mutable_description())["en"] = "Eject medium";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_name(PbOperation_Name(PROTECT));
|
||||
(*parameters->mutable_description())["en"] = "Protect medium";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_name(PbOperation_Name(UNPROTECT));
|
||||
(*parameters->mutable_description())["en"] = "Unprotect medium";
|
||||
|
||||
parameters = operation_info->add_operations();
|
||||
parameters->set_name(PbOperation_Name(OPERATION_INFO));
|
||||
|
||||
result.set_status(true);
|
||||
|
||||
|
@ -276,15 +276,19 @@ void RasctlDisplay::DisplayMappingInfo(const PbMappingInfo& mapping_info)
|
||||
|
||||
void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info)
|
||||
{
|
||||
// Creates a sorted list
|
||||
list<PbOperationParameters> operations = { operation_info.operations().begin(), operation_info.operations().end() };
|
||||
operations.sort([](const auto& a, const auto& b) { return a.name() < b.name(); });
|
||||
|
||||
cout << "Remote operations supported by rascsi and their parameters:" << endl;
|
||||
for (auto& operation : operation_info.operations()) {
|
||||
cout << " " << operation.operation();
|
||||
for (const auto& operation : operations) {
|
||||
cout << " " << operation.name();
|
||||
if (!operation.description().empty()) {
|
||||
cout << " (" << operation.description().at("en") << ")";
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
for (auto& parameter : operation.parameters()) {
|
||||
for (const auto& parameter : operation.parameters()) {
|
||||
cout << " " << parameter.name() << ": " << parameter.type()
|
||||
<< (parameter.is_mandatory() ? ", mandatory" : ", optional");
|
||||
if (!parameter.description().empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user