Skip to content

[21698] Add -v or --version to cli command tool #5401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>fastdds</name>
<version>3.1.0</version>
<description>
*eprosima Fast DDS* is a C++ implementation of the DDS (Data Distribution Service) standard of the OMG (Object Management Group). eProsima Fast DDS implements the RTPS (Real Time Publish Subscribe) protocol, which provides publisher-subscriber communications over unreliable transports such as UDP, as defined and maintained by the Object Management Group (OMG) consortium. RTPS is also the wire interoperability protocol defined for the Data Distribution Service (DDS) standard. *eProsima Fast DDS* expose an API to access directly the RTPS protocol, giving the user full access to the protocol internals.
eProsima Fast DDS is a C++ implementation of the DDS (Data Distribution Service) standard of the OMG (Object Management Group). eProsima Fast DDS implements the RTPS (Real Time Publish Subscribe) protocol, which provides publisher-subscriber communications over unreliable transports such as UDP, as defined and maintained by the Object Management Group (OMG) consortium. RTPS is also the wire interoperability protocol defined for the Data Distribution Service (DDS) standard. eProsima Fast DDS expose an API to access directly the RTPS protocol, giving the user full access to the protocol internals.
</description>
<maintainer email="[email protected]">Raul Sanchez Mateos</maintainer>
<maintainer email="[email protected]">Miguel Company</maintainer>
Expand Down
1 change: 1 addition & 0 deletions test/system/tools/fastdds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if(Python3_Interpreter_FOUND)

set(TESTS
test_fastdds_installed
test_fastdds_version
test_fastdds_discovery
test_ros_discovery
test_fastdds_shm
Expand Down
9 changes: 9 additions & 0 deletions test/system/tools/fastdds/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def test_fastdds_installed(install_path):
print('test_fastdds_installed FAILED')
sys.exit(ret)

def test_fastdds_version(install_path):
"""Test that fastdds version is printed correctly."""
args = '-v'
ret = subprocess.call(cmd(install_path, args=args), shell=True)
if 0 != ret:
print('test_fastdds_version FAILED')
sys.exit(ret)

def test_fastdds_shm(install_path):
"""Test that shm command runs."""
Expand Down Expand Up @@ -198,6 +205,8 @@ def get_paths(install_path):
tests = {
'test_fastdds_installed':
lambda: test_fastdds_installed(fastdds_tool_path),
'test_fastdds_version':
lambda: test_fastdds_version(fastdds_tool_path),
'test_fastdds_discovery': lambda: test_fastdds_discovery(
fastdds_tool_path, setup_script_path),
'test_ros_discovery':
Expand Down
7 changes: 7 additions & 0 deletions tools/fastdds/discovery/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def __init__(self, argv):
(len(argv) == 1 and argv[0] == '--help')
):
print(self.__edit_tool_help(result.stdout))
elif (
(len(argv) == 1 and argv[0] == '-v') or
(len(argv) == 1 and argv[0] == '--version')
):
result = subprocess.run([tool_path, '-v'])
if result.returncode != 0:
sys.exit(result.returncode)
else:
# Call the tool
result = subprocess.run([tool_path] + argv)
Expand Down
4 changes: 3 additions & 1 deletion tools/fastdds/fastdds.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def __init__(self):
parser.add_argument('command',
nargs='?',
help='Command to run')
parser.add_argument('-v', '--version', action='store_true', help='Print Fast DDS version')

args = parser.parse_args(sys.argv[1:2])

Expand All @@ -86,6 +87,8 @@ def __init__(self):
print('Invalid command')
else:
getattr(self, args.command)()
elif args.version:
DiscoveryParser(['-v'])
else:
parser.print_help()

Expand Down Expand Up @@ -122,7 +125,6 @@ def xml(self):
except ImportError:
sys.exit(1)


if __name__ == '__main__':

FastDDSParser()
8 changes: 8 additions & 0 deletions tools/fds/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "server.h"
#include <fastdds/config.hpp>

#include <condition_variable>
#include <csignal>
Expand Down Expand Up @@ -109,6 +110,13 @@ int fastdds_discovery_server(
return 0;
}

// Show version if asked to
if (options[VERSION])
{
std::cout << "Fast DDS version: " << FASTDDS_VERSION_STR << std::endl;
return 0;
}

DomainParticipantQos participantQos;

if (nullptr != options[XML_FILE])
Expand Down
4 changes: 4 additions & 0 deletions tools/fds/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum optionIndex
{
UNKNOWN,
HELP,
VERSION,
SERVERID,
UDPADDRESS,
UDP_PORT,
Expand Down Expand Up @@ -62,6 +63,9 @@ const option::Descriptor usage[] = {
{ HELP, 0, "h", "help", Arg::None,
" -h \t--help Produce help message.\n" },

{ VERSION, 0, "v", "version", Arg::None,
" -v \t--version Show Fast DDS version information.\n" },

{ UDPADDRESS, 0, "l", "udp-address", Arg::OptionalAny,
" -l \t--udp-address IPv4/IPv6 address chosen to listen the clients. Defaults\n"
"\t to any (0.0.0.0/::0). Instead of an address, a name can\n"
Expand Down
Loading