1b1994897Sopenharmony_ci/*
2b1994897Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3b1994897Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4b1994897Sopenharmony_ci * you may not use this file except in compliance with the License.
5b1994897Sopenharmony_ci * You may obtain a copy of the License at
6b1994897Sopenharmony_ci *
7b1994897Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0
8b1994897Sopenharmony_ci *
9b1994897Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10b1994897Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11b1994897Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12b1994897Sopenharmony_ci * See the License for the specific language governing permissions and
13b1994897Sopenharmony_ci * limitations under the License.
14b1994897Sopenharmony_ci */
15b1994897Sopenharmony_ci
16b1994897Sopenharmony_ci#include "verify.h"
17b1994897Sopenharmony_ci
18b1994897Sopenharmony_ci#include "utils/pandargs.h"
19b1994897Sopenharmony_ci
20b1994897Sopenharmony_civoid PrintHelp(panda::PandArgParser &pa_parser)
21b1994897Sopenharmony_ci{
22b1994897Sopenharmony_ci    std::cerr << "Usage:" << std::endl;
23b1994897Sopenharmony_ci    std::cerr << "ark_verifier [options] input_file" << std::endl;
24b1994897Sopenharmony_ci    std::cerr << "Supported options:" << std::endl;
25b1994897Sopenharmony_ci    std::cerr << pa_parser.GetHelpString() << std::endl;
26b1994897Sopenharmony_ci}
27b1994897Sopenharmony_ci
28b1994897Sopenharmony_cibool PorcessArgs(panda::PandArgParser &pa_parser, const panda::PandArg<std::string> &input_file, int argc,
29b1994897Sopenharmony_ci                 const char **argv)
30b1994897Sopenharmony_ci{
31b1994897Sopenharmony_ci    if (!pa_parser.Parse(argc, argv)) {
32b1994897Sopenharmony_ci        PrintHelp(pa_parser);
33b1994897Sopenharmony_ci        return false;
34b1994897Sopenharmony_ci    }
35b1994897Sopenharmony_ci
36b1994897Sopenharmony_ci    if (input_file.GetValue().empty()) {
37b1994897Sopenharmony_ci        PrintHelp(pa_parser);
38b1994897Sopenharmony_ci        return false;
39b1994897Sopenharmony_ci    }
40b1994897Sopenharmony_ci
41b1994897Sopenharmony_ci    return true;
42b1994897Sopenharmony_ci}
43b1994897Sopenharmony_ci
44b1994897Sopenharmony_ciint main(int argc, const char **argv)
45b1994897Sopenharmony_ci{
46b1994897Sopenharmony_ci    panda::PandArg<bool> help("help", false, "Print this message and exit");
47b1994897Sopenharmony_ci    panda::PandArg<std::string> input_file("input_file", "", "Path to the abc file");
48b1994897Sopenharmony_ci
49b1994897Sopenharmony_ci    panda::PandArgParser pa_parser;
50b1994897Sopenharmony_ci    pa_parser.Add(&help);
51b1994897Sopenharmony_ci    pa_parser.Add(&input_file);
52b1994897Sopenharmony_ci
53b1994897Sopenharmony_ci    if (!PorcessArgs(pa_parser, input_file, argc, argv)) {
54b1994897Sopenharmony_ci        return 1;
55b1994897Sopenharmony_ci    }
56b1994897Sopenharmony_ci
57b1994897Sopenharmony_ci    return Verify(input_file.GetValue()) ? 0 : 1;
58b1994897Sopenharmony_ci}