1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# Copyright (c) 2024 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import enum
17from coreImpl import compare_sdk_file
18
19
20class ToolNameType(enum.Enum):
21    COMPARE = 'compare'
22
23
24tool_name_type_set = [
25    member.value for name_tool,
26    member in ToolNameType.__members__.items()
27]
28
29
30class FormatType(enum.Enum):
31    JSON = 'json'
32    EXCEL = 'excel'
33
34
35format_set = [
36    member.value for name_format,
37    member in FormatType.__members__.items()
38]
39
40
41def run_tools(options):
42    tool_name = options.tool_name
43    if tool_name == ToolNameType["COMPARE"].value:
44        compare_sdk_file.start_do_diff(options.old_sdk_file_path, options.new_sdk_file_path, options.output_file_path)
45
46
47class Config(object):
48    name = 'compare'
49    version = '1.1.0'
50    description = 'Compare the differences between two SDK version files'
51    commands = [
52        {
53            "name": "--tool-name",
54            "abbr": "-N",
55            "required": True,
56            "choices": tool_name_type_set,
57            "type": str,
58            "default": ToolNameType["COMPARE"],
59            "help": "工具名称"
60        },
61        {
62            "name": "--old-sdk-file-path",
63            "abbr": "-P",
64            "required": True,
65            "type": str,
66            "help": "旧版本SDK路径"
67        },
68        {
69            "name": "--new-sdk-file-path",
70            "abbr": "-M",
71            "required": True,
72            "type": str,
73            "help": "新版本SDK路径"
74        },
75        {
76            "name": "--output-file-path",
77            "abbr": "-O",
78            "required": False,
79            "type": str,
80            "help": "输出路径"
81        }
82    ]
83
84