• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "verify.h"
17 
18 #include "utils/pandargs.h"
19 
PrintHelp(panda::PandArgParser & pa_parser)20 void PrintHelp(panda::PandArgParser &pa_parser)
21 {
22     std::cerr << "Usage:" << std::endl;
23     std::cerr << "ark_verifier [options] input_file" << std::endl;
24     std::cerr << "Supported options:" << std::endl;
25     std::cerr << pa_parser.GetHelpString() << std::endl;
26 }
27 
PorcessArgs(panda::PandArgParser & pa_parser,const panda::PandArg<std::string> & input_file,int argc,const char ** argv)28 bool PorcessArgs(panda::PandArgParser &pa_parser, const panda::PandArg<std::string> &input_file, int argc,
29                  const char **argv)
30 {
31     if (!pa_parser.Parse(argc, argv)) {
32         PrintHelp(pa_parser);
33         return false;
34     }
35 
36     if (input_file.GetValue().empty()) {
37         PrintHelp(pa_parser);
38         return false;
39     }
40 
41     return true;
42 }
43 
main(int argc,const char ** argv)44 int main(int argc, const char **argv)
45 {
46     panda::PandArg<bool> help("help", false, "Print this message and exit");
47     panda::PandArg<std::string> input_file("input_file", "", "Path to the abc file");
48 
49     panda::PandArgParser pa_parser;
50     pa_parser.Add(&help);
51     pa_parser.Add(&input_file);
52 
53     if (!PorcessArgs(pa_parser, input_file, argc, argv)) {
54         return 1;
55     }
56 
57     return Verify(input_file.GetValue()) ? 0 : 1;
58 }