mirror of
https://github.com/akuker/RASCSI.git
synced 2025-01-02 09:35:58 +00:00
Support for localized descriptions
This commit is contained in:
parent
b4ff4f52ab
commit
d3af9a142c
@ -162,8 +162,8 @@ enum PbOperation {
|
|||||||
// The operation parameter meta data
|
// The operation parameter meta data
|
||||||
message PbOperationParameter {
|
message PbOperationParameter {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
// Optional description
|
// Optional short localized description, key is the lower case locale (e.g. en, de)
|
||||||
string description = 2;
|
map<string, string> description = 2;
|
||||||
// "int" or "string"
|
// "int" or "string"
|
||||||
string type = 3;
|
string type = 3;
|
||||||
// There is no specific set of values if empty
|
// There is no specific set of values if empty
|
||||||
@ -174,8 +174,8 @@ message PbOperationParameter {
|
|||||||
// The list of parameters supported by an operation
|
// The list of parameters supported by an operation
|
||||||
message PbOperationParameters {
|
message PbOperationParameters {
|
||||||
string operation = 1;
|
string operation = 1;
|
||||||
// Optional description
|
// Optional short localized description, key is the lower case locale (e.g. en, de)
|
||||||
string description = 2;
|
map<string, string> description = 2;
|
||||||
repeated PbOperationParameter parameters = 3;
|
repeated PbOperationParameter parameters = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,16 +344,33 @@ PbOperationInfo *RascsiResponse::GetOperationInfo(PbResult& result)
|
|||||||
|
|
||||||
parameters = operation_info->add_operations();
|
parameters = operation_info->add_operations();
|
||||||
parameters->set_operation(PbOperation_Name(ATTACH));
|
parameters->set_operation(PbOperation_Name(ATTACH));
|
||||||
parameters->set_description("Attach device, one of the parameters below is required");
|
(*parameters->mutable_description())["en"] = "Attach device, one of the parameters below is required";
|
||||||
parameter = parameters->add_parameters();
|
parameter = parameters->add_parameters();
|
||||||
parameter->set_name("name");
|
parameter->set_name("name");
|
||||||
parameter->set_description("Image file name");
|
(*parameter->mutable_description())["en"] = "Image file name";
|
||||||
parameter->set_type("string");
|
parameter->set_type("string");
|
||||||
parameter = parameters->add_parameters();
|
parameter = parameters->add_parameters();
|
||||||
parameter->set_name("interfaces");
|
parameter->set_name("interfaces");
|
||||||
parameter->set_description("Comma-separated list of network interfaces");
|
(*parameter->mutable_description())["en"] = "Comma-separated list of network interfaces";
|
||||||
parameter->set_type("string");
|
parameter->set_type("string");
|
||||||
|
|
||||||
|
parameters = operation_info->add_operations();
|
||||||
|
parameters->set_operation(PbOperation_Name(DETACH));
|
||||||
|
(*parameters->mutable_description())["en"] = "Detach device";
|
||||||
|
|
||||||
|
parameters = operation_info->add_operations();
|
||||||
|
parameters->set_operation(PbOperation_Name(DETACH_ALL));
|
||||||
|
(*parameters->mutable_description())["en"] = "Detach all devices";
|
||||||
|
|
||||||
|
parameters = operation_info->add_operations();
|
||||||
|
parameters->set_operation(PbOperation_Name(START));
|
||||||
|
(*parameters->mutable_description())["en"] = "Start device";
|
||||||
|
|
||||||
|
parameters = operation_info->add_operations();
|
||||||
|
parameters->set_operation(PbOperation_Name(STOP));
|
||||||
|
(*parameters->mutable_description())["en"] = "Stop device";
|
||||||
|
|
||||||
|
|
||||||
parameters = operation_info->add_operations();
|
parameters = operation_info->add_operations();
|
||||||
parameters->set_operation(PbOperation_Name(OPERATION_INFO));
|
parameters->set_operation(PbOperation_Name(OPERATION_INFO));
|
||||||
|
|
||||||
|
@ -277,18 +277,18 @@ void RasctlDisplay::DisplayMappingInfo(const PbMappingInfo& mapping_info)
|
|||||||
void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info)
|
void RasctlDisplay::DisplayOperationInfo(const PbOperationInfo& operation_info)
|
||||||
{
|
{
|
||||||
cout << "Remote operations supported by rascsi and their parameters:" << endl;
|
cout << "Remote operations supported by rascsi and their parameters:" << endl;
|
||||||
for (const auto& operation : operation_info.operations()) {
|
for (auto& operation : operation_info.operations()) {
|
||||||
cout << " " << operation.operation();
|
cout << " " << operation.operation();
|
||||||
if (!operation.description().empty()) {
|
if (!operation.description().empty()) {
|
||||||
cout << " (" << operation.description() << ")";
|
cout << " (" << operation.description().at("en") << ")";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
for (const auto& parameter : operation.parameters()) {
|
for (auto& parameter : operation.parameters()) {
|
||||||
cout << " " << parameter.name() << ": " << parameter.type()
|
cout << " " << parameter.name() << ": " << parameter.type()
|
||||||
<< (parameter.is_mandatory() ? ", mandatory" : ", optional");
|
<< (parameter.is_mandatory() ? ", mandatory" : ", optional");
|
||||||
if (!parameter.description().empty()) {
|
if (!parameter.description().empty()) {
|
||||||
cout << " (" << parameter.description() << ")";
|
cout << " (" << parameter.description().at("en") << ")";
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user