xref: /aosp_15_r20/external/zucchini/main_utils.h (revision a03ca8b91e029cd15055c20c78c2e087c84792e4)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_ZUCCHINI_MAIN_UTILS_H_
6 #define COMPONENTS_ZUCCHINI_MAIN_UTILS_H_
7 
8 #include <iosfwd>
9 
10 #include "components/zucchini/zucchini.h"
11 
12 // Utilities to run Zucchini command based on command-line input, and to print
13 // help messages.
14 
15 namespace base {
16 
17 class CommandLine;
18 
19 }  // namespace base
20 
21 // To add a new Zucchini command:
22 // 1. Declare the command's main function in zucchini_command.h. Its signature
23 //    must match CommandFunction.
24 // 2. Define the command's main function in zucchini_command.cc.
25 // 3. Add a new entry into |kCommands| in main_utils.cc.
26 
27 // Searches |command_line| for Zucchini commands. If a unique command is found,
28 // runs it (passes |out| and |err|), and logs resource usage. Otherwise prints
29 // help message to |err|. Returns Zucchini status code for error handling.
30 zucchini::status::Code RunZucchiniCommand(const base::CommandLine& command_line,
31                                           std::ostream& out,
32                                           std::ostream& err);
33 
34 #endif  // COMPONENTS_ZUCCHINI_MAIN_UTILS_H_
35