Skip to content

Commit

Permalink
Improve info page
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed Jan 22, 2025
1 parent 55db17e commit 1f0eaa2
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/nanosaur/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from nanosaur import __version__
from nanosaur.utilities import Params, get_nanosaur_home
from nanosaur import workspace
from nanosaur.robot import parser_robot_menu
from nanosaur.robot import parser_robot_menu, robot_start, robot_stop
from nanosaur.simulation import parser_simulation_menu
from nanosaur.swarm import parser_swarm_menu
from nanosaur.prompt_colors import TerminalFormatter
Expand Down Expand Up @@ -82,13 +82,13 @@ def info(platform, params: Params, args):
# Print simulation tools if they exist
if 'simulation_tool' in params:
print(f"\n{TerminalFormatter.color_text('Simulation Tool:', bold=True)} {params['simulation_tool']}")

# Print all workspaces installed
print(TerminalFormatter.color_text("\nInstalled Workspaces:", bold=True))
for ws_name, ws_path in workspace.get_workspaces_path(params).items():
# Get the workspace path if it exists
print(f" {TerminalFormatter.color_text(ws_name, bold=True)}: {TerminalFormatter.clickable_path(ws_path)}")

# Print installed workspaces
workspaces = workspace.get_workspaces_path(params)
if workspaces or args.verbose:
print(TerminalFormatter.color_text("\nInstalled Workspaces:", bold=True))
for ws_name, ws_path in workspaces.items():
# Get the workspace path if it exists
print(f" {TerminalFormatter.color_text(ws_name, bold=True)}: {TerminalFormatter.clickable_path(ws_path)}")
# Print all robot configurations
if args.verbose:
# Print device information
Expand Down Expand Up @@ -147,6 +147,15 @@ def install(platform, params: Params, args):
params['mode'] = install_type


def robot_control(params, subparsers):
robot = RobotList.get_robot(params).name
robot_name = TerminalFormatter.color_text(robot, color='green', bold=True)
parser_wakeup = subparsers.add_parser('wake-up', help=f"Start {robot_name} (same as 'nanosaur robot start')")
parser_wakeup.set_defaults(func=robot_start)
# Subcommand: shutdown
parser_shutdown = subparsers.add_parser('shutdown', help="Shutdown the robot (same as 'nanosaur robot stop')")
parser_shutdown.set_defaults(func=robot_stop)

def main():
# Load the parameters
params = Params.load(DEFAULT_PARAMS, home_folder=NANOSAUR_HOME_NAME, params_file_name=NANOSAUR_CONFIG_FILE_NAME)
Expand Down Expand Up @@ -176,12 +185,11 @@ def main():
parser_info.set_defaults(func=info)

# Subcommand: install (hidden if workspace already exists)
# if 'mode' in params and params['mode'] in ['developer', 'maintainer']:
parser_install = subparsers.add_parser('install', help=f"Install nanosaur on your {device_type}")
# else:
# parser_install = subparsers.add_parser('install')
if 'mode' not in params:
parser_install = subparsers.add_parser('install', help=f"Install nanosaur on your {device_type}")
else:
parser_install = subparsers.add_parser('install')
# Add simulation install subcommand
parser_install.add_argument('--developer', '--dev', action='store_true', help="Install developer workspace")
parser_install.add_argument('--force', action='store_true', help="Force the update")
parser_install.add_argument('--all-platforms', action='store_true', help="Install for all platforms")
parser_install.set_defaults(func=install)
Expand All @@ -203,6 +211,10 @@ def main():
# Subcommand: swarm (with a sub-menu for swarm operations)
parser_swarm = parser_swarm_menu(subparsers, params)

# Subcommand: wakeup (with a sub-menu for wakeup operations)
if 'mode' in params:
robot_control(params, subparsers)

# Enable tab completion
argcomplete.autocomplete(parser)

Expand Down

0 comments on commit 1f0eaa2

Please sign in to comment.