Skip to content

Commit 536f2ce

Browse files
committed
Resolve comments
Signed-off-by: Blake McHale <[email protected]>
1 parent 3dbb652 commit 536f2ce

File tree

4 files changed

+24
-30
lines changed

4 files changed

+24
-30
lines changed

greenwave_monitor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ if(BUILD_TESTING)
111111
)
112112

113113
# Add ncurses frontend tests
114-
ament_add_pytest_test(test_ncurses_frontend test/test_ncurses_frontend.py
114+
ament_add_pytest_test(test_ncurses_frontend_argparse test/test_ncurses_frontend_argparse.py
115115
TIMEOUT 120
116116
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
117117
)

greenwave_monitor/greenwave_monitor/ncurses_frontend.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
class GreenwaveNcursesFrontend(Node):
4242
"""Ncurses frontend for Greenwave Monitor."""
4343

44-
def __init__(self, hide_unmonitored: bool = False):
44+
def __init__(self, show_only_monitored: bool = False):
4545
"""Initialize the ncurses frontend node."""
4646
super().__init__('greenwave_ncurses_frontend')
4747

@@ -60,7 +60,7 @@ def __init__(self, hide_unmonitored: bool = False):
6060
self.input_buffer = ''
6161
self.status_message = ''
6262
self.status_timeout = 0
63-
self.show_only_monitored = hide_unmonitored
63+
self.show_only_monitored = show_only_monitored
6464

6565
# Initialize UI adaptor
6666
self.ui_adaptor = GreenwaveUiAdaptor(self)
@@ -452,19 +452,12 @@ def curses_main(stdscr, node):
452452
def parse_args():
453453
"""Parse command-line arguments."""
454454
parser = argparse.ArgumentParser(
455-
description='Ncurses-based frontend for Greenwave Monitor',
456-
add_help=False
455+
description='Ncurses-based frontend for Greenwave Monitor'
457456
)
458457
parser.add_argument(
459-
'--help',
460-
action='help',
461-
default=argparse.SUPPRESS,
462-
help='Show this help message and exit'
463-
)
464-
parser.add_argument(
465-
'--hide-unmonitored',
458+
'--show-only-monitored',
466459
action='store_true',
467-
help='Hide unmonitored topics on initialization'
460+
help='Show only monitored topics on initialization'
468461
)
469462
return parser.parse_known_args()
470463

@@ -473,7 +466,7 @@ def main(args=None):
473466
"""Entry point for the ncurses frontend application."""
474467
parsed_args, ros_args = parse_args()
475468
rclpy.init(args=ros_args)
476-
node = GreenwaveNcursesFrontend(hide_unmonitored=parsed_args.hide_unmonitored)
469+
node = GreenwaveNcursesFrontend(show_only_monitored=parsed_args.show_only_monitored)
477470
thread = None
478471

479472
def signal_handler(signum, frame):

greenwave_monitor/scripts/ncurses_dashboard

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# Parse command line arguments
2424
DEMO_MODE=false
2525
LOG_DIR=""
26-
HIDE_UNMONITORED=false
26+
SHOW_ONLY_MONITORED=false
2727
MONITOR_ARGS=()
2828

2929
show_help() {
@@ -34,7 +34,7 @@ show_help() {
3434
echo "OPTIONS:"
3535
echo " --demo, --test Launch demo publisher nodes for testing"
3636
echo " --log-dir DIR Enable logging to specified directory"
37-
echo " --hide-unmonitored Hide unmonitored topics on initialization"
37+
echo " --show-only-monitored Show only monitored topics on initialization"
3838
echo " --help, -h Show this help message"
3939
echo ""
4040
echo "MONITOR_ARGS are passed directly to the greenwave_monitor node"
@@ -58,8 +58,8 @@ while [[ $# -gt 0 ]]; do
5858
LOG_DIR="$2"
5959
shift 2
6060
;;
61-
--hide-unmonitored)
62-
HIDE_UNMONITORED=true
61+
--show-only-monitored)
62+
SHOW_ONLY_MONITORED=true
6363
shift
6464
;;
6565
--help|-h)
@@ -121,11 +121,12 @@ echo "Monitor process started with PID: $MONITOR_PID"
121121
# Launch ncurses frontend in the foreground
122122
echo "Starting ncurses TUI..."
123123
echo "Controls: a=Add Topic, r=Remove, f=Set Frequency, c=Clear Freq, q=Quit"
124+
# NOTE: add proper argument parsing to the ncurses frontend if more than one argument is added here
124125
FRONTEND_ARGS=()
125-
if [ "$HIDE_UNMONITORED" = "true" ]; then
126-
FRONTEND_ARGS+=("--hide-unmonitored")
126+
if [ "$SHOW_ONLY_MONITORED" = "true" ]; then
127+
FRONTEND_ARGS+=("--show-only-monitored")
127128
fi
128129
python3 -m greenwave_monitor.ncurses_frontend "${FRONTEND_ARGS[@]}"
129130

130131
# Note: We don't need to explicitly exit here because the trap will handle cleanup
131-
# when the ncurses frontend exits
132+
# when the ncurses frontend exits

greenwave_monitor/test/test_ncurses_frontend.py renamed to greenwave_monitor/test/test_ncurses_frontend_argparse.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@
2525
class TestParseArgs:
2626
"""Test argument parsing for ncurses frontend."""
2727

28-
def test_default_hide_unmonitored_false(self, monkeypatch):
29-
"""Test that hide_unmonitored defaults to False."""
28+
def test_default_show_only_monitored_false(self, monkeypatch):
29+
"""Test that show_only_monitored defaults to False."""
3030
monkeypatch.setattr(sys, 'argv', ['ncurses_frontend'])
3131
from greenwave_monitor.ncurses_frontend import parse_args
3232
parsed_args, _ = parse_args()
33-
assert parsed_args.hide_unmonitored is False
33+
assert parsed_args.show_only_monitored is False
3434

35-
def test_hide_unmonitored_long_flag(self, monkeypatch):
36-
"""Test --hide-unmonitored flag enables hide_unmonitored."""
37-
monkeypatch.setattr(sys, 'argv', ['ncurses_frontend', '--hide-unmonitored'])
35+
def test_show_only_monitored_long_flag(self, monkeypatch):
36+
"""Test --show-only-monitored flag enables show_only_monitored."""
37+
monkeypatch.setattr(sys, 'argv', ['ncurses_frontend', '--show-only-monitored'])
3838
from greenwave_monitor.ncurses_frontend import parse_args
3939
parsed_args, _ = parse_args()
40-
assert parsed_args.hide_unmonitored is True
40+
assert parsed_args.show_only_monitored is True
4141

4242
def test_ros_args_passthrough(self, monkeypatch):
4343
"""Test that ROS arguments are passed through."""
4444
monkeypatch.setattr(
4545
sys, 'argv',
46-
['ncurses_frontend', '--hide-unmonitored', '--ros-args', '-r', '__node:=my_node']
46+
['ncurses_frontend', '--show-only-monitored', '--ros-args', '-r', '__node:=my_node']
4747
)
4848
from greenwave_monitor.ncurses_frontend import parse_args
4949
parsed_args, ros_args = parse_args()
50-
assert parsed_args.hide_unmonitored is True
50+
assert parsed_args.show_only_monitored is True
5151
assert '--ros-args' in ros_args
5252
assert '-r' in ros_args
5353
assert '__node:=my_node' in ros_args

0 commit comments

Comments
 (0)