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