blob: 493948790a7b4822310851b7183152d13a90b082 [file] [log] [blame]
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Encapsulate the sub modules of crosh.
pub mod base;
pub mod dev;
pub mod dispatcher;
pub mod legacy;
pub mod util;
use dispatcher::Dispatcher;
use sys_util::error;
pub fn setup_dispatcher() -> Dispatcher {
let mut dispatcher = Dispatcher::new();
if util::dev_commands_included() {
legacy::register_dev_mode_commands(&mut dispatcher);
dev::register(&mut dispatcher);
if util::usb_commands_included() {
legacy::register_removable_commands(&mut dispatcher);
base::register(&mut dispatcher);
legacy::register(&mut dispatcher);
if let Err(err) = dispatcher.validate() {
// Use error! too so that the message is included in the syslog.
error!("FATAL: {}", err);
panic!("FATAL: {}", err);
mod tests {
use super::*;
fn test_validate_registered_commands() {