1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "cmd_parser.h"
17 #include "task_handle.h"
18 #include "compression_parser.h"
19 
20 using namespace std;
21 using namespace OHOS::Global::Restool;
22 namespace {
ProccssHap(PackageParser &packageParser)23 uint32_t ProccssHap(PackageParser &packageParser)
24 {
25     TaskHandle taskHandle;
26     return taskHandle.HandlePackage(packageParser);
27 }
28 }
29 
main(int argc, char *argv[])30 int main(int argc, char *argv[])
31 {
32     if (argv == nullptr) {
33         cerr << "Error: argv null" << endl;
34         return RESTOOL_ERROR;
35     }
36     auto &parser = CmdParser<PackageParser>::GetInstance();
37     if (parser.Parse(argc, argv) != RESTOOL_SUCCESS) {
38         parser.ShowUseage();
39         return RESTOOL_ERROR;
40     }
41 
42     auto &packageParser = parser.GetCmdParser();
43     if (ProccssHap(packageParser) != RESTOOL_SUCCESS) {
44         return RESTOOL_ERROR;
45     }
46     cout << "Info: restool resources compile success." << endl;
47     if (CompressionParser::GetCompressionParser()->GetMediaSwitch()) {
48         cout << CompressionParser::GetCompressionParser()->PrintTransMessage() << endl;
49     }
50     return RESTOOL_SUCCESS;
51 }
52