9
9
10
10
#include " cxxsemaphore.hpp"
11
11
#include " cxxshm.hpp"
12
+ #include " generated/version_info.hpp"
12
13
#include < array>
13
14
#include < chrono>
14
15
#include < cmath>
@@ -82,32 +83,38 @@ int main(int argc, char **argv) {
82
83
}
83
84
84
85
// all command line arguments
85
- options.add_options ()(" n,name-prefix" ,
86
- " name prefix of the shared memory objects" ,
87
- cxxopts::value<std::string>()->default_value (" modbus_" ));
88
- options.add_options ()(" address-base" ,
89
- " Numerical base (radix) that is used for the addresses (see "
90
- " https://en.cppreference.com/w/cpp/string/basic_string/stoul)" ,
91
- cxxopts::value<int >()->default_value (" 0" ));
92
- options.add_options ()(" value-base" ,
93
- " Numerical base (radix) that is used for the values (see "
94
- " https://en.cppreference.com/w/cpp/string/basic_string/stoul)" ,
95
- cxxopts::value<int >()->default_value (" 0" ));
96
- options.add_options ()(" p,passthrough" , " write passthrough all executed commands to stdout" );
97
- options.add_options ()(" bash" , " passthrough as bash script. No effect i '--passthrough' is not set" );
98
- options.add_options ()(" valid-hist" , " add only valid commands to command history" );
99
- options.add_options ()(" h,help" , " print usage" );
100
- options.add_options ()(" v,verbose" , " print what is written to the registers" );
101
- options.add_options ()(" version" , " print version information" );
102
- options.add_options ()(" license" , " show licenses" );
103
- options.add_options ()(" data-types" , " show list of supported data type identifiers" );
104
- options.add_options ()(" constants" , " list string constants that can be used as value" );
105
- options.add_options ()(" semaphore" ,
106
- " protect the shared memory with an existing named semaphore against simultaneous access" ,
107
- cxxopts::value<std::string>());
108
- options.add_options ()(" semaphore-timeout" ,
109
- " maximum time (in seconds) to wait for semaphore (default: 0.1)" ,
110
- cxxopts::value<double >()->default_value (" 0.1" ));
86
+ options.add_options (" shared memory" )(" n,name-prefix" ,
87
+ " name prefix of the shared memory objects" ,
88
+ cxxopts::value<std::string>()->default_value (" modbus_" ));
89
+ options.add_options (" settings" )(" address-base" ,
90
+ " Numerical base (radix) that is used for the addresses (see "
91
+ " https://en.cppreference.com/w/cpp/string/basic_string/stoul)" ,
92
+ cxxopts::value<int >()->default_value (" 0" ));
93
+ options.add_options (" settings" )(" value-base" ,
94
+ " Numerical base (radix) that is used for the values (see "
95
+ " https://en.cppreference.com/w/cpp/string/basic_string/stoul)" ,
96
+ cxxopts::value<int >()->default_value (" 0" ));
97
+ options.add_options (" settings" )(" p,passthrough" , " write passthrough all executed commands to stdout" );
98
+ options.add_options (" settings" )(" bash" , " passthrough as bash script. No effect i '--passthrough' is not set" );
99
+ options.add_options (" settings" )(" valid-hist" , " add only valid commands to command history" );
100
+ options.add_options (" other" )(" h,help" , " print usage" );
101
+ options.add_options (" other" )(" v,verbose" , " print what is written to the registers" );
102
+ options.add_options (" version information" )(" version" , " print version and exit" );
103
+ options.add_options (" version information" )(" longversion" ,
104
+ " print version (including compiler and system info) and exit" );
105
+ options.add_options (" version information" )(" shortversion" , " print version (only version string) and exit" );
106
+ options.add_options (" version information" )(" git-hash" , " print git hash" );
107
+ options.add_options (" other" )(" license" , " show licenses" );
108
+ options.add_options (" other" )(" license-full" , " show licences (full license text)" );
109
+ options.add_options (" other" )(" data-types" , " show list of supported data type identifiers" );
110
+ options.add_options (" other" )(" constants" , " list string constants that can be used as value" );
111
+ options.add_options (" shared memory" )(
112
+ " semaphore" ,
113
+ " protect the shared memory with an existing named semaphore against simultaneous access" ,
114
+ cxxopts::value<std::string>());
115
+ options.add_options (" shared memory" )(" semaphore-timeout" ,
116
+ " maximum time (in seconds) to wait for semaphore (default: 0.1)" ,
117
+ cxxopts::value<double >()->default_value (" 0.1" ));
111
118
112
119
// parse arguments
113
120
cxxopts::ParseResult args;
@@ -168,9 +175,26 @@ int main(int argc, char **argv) {
168
175
}
169
176
170
177
// print version
178
+ if (args.count (" shortversion" )) {
179
+ std::cout << PROJECT_VERSION << ' \n ' ;
180
+ return EX_OK;
181
+ }
182
+
171
183
if (args.count (" version" )) {
172
- std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << " (compiled with " << COMPILER_INFO << " on "
173
- << SYSTEM_INFO << ' )' << ' \n ' ;
184
+ std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << ' \n ' ;
185
+ return EX_OK;
186
+ }
187
+
188
+ if (args.count (" longversion" )) {
189
+ std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << ' \n ' ;
190
+ std::cout << " compiled with " << COMPILER_INFO << ' \n ' ;
191
+ std::cout << " on system " << SYSTEM_INFO << ' \n ' ;
192
+ std::cout << " from git commit " << RCS_HASH << ' \n ' ;
193
+ return EX_OK;
194
+ }
195
+
196
+ if (args.count (" git-hash" )) {
197
+ std::cout << RCS_HASH << ' \n ' ;
174
198
return EX_OK;
175
199
}
176
200
@@ -180,6 +204,11 @@ int main(int argc, char **argv) {
180
204
return EX_OK;
181
205
}
182
206
207
+ if (args.count (" license-full" )) {
208
+ print_licenses (std::cout, true );
209
+ return EX_OK;
210
+ }
211
+
183
212
auto print_data_types = []() {
184
213
std::cout << " Supported data types:" << ' \n ' ;
185
214
std::cout << " - Float:" << ' \n ' ;
0 commit comments