Command verification method and device, electronic equipment and storage medium

By automatically verifying the CLI commands entered by the user, the problems of complexity of CLI instructions and lack of targeted prompt information are solved, and the accuracy of command execution and the friendliness of CLI operations are improved.

CN119883370AActive Publication Date: 2025-04-25INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411997001.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

In the prior art, the complexity and lack of targeted prompt information of CLI instructions make it difficult for users to accurately understand the command syntax and locate problems when executing commands, resulting in command execution errors.

Method used

By extracting the target parameters and parameter values ​​in the command input by the user, obtaining parameter data information, including parameter position, type, value and relationship, performing automatic verification, generating command verification results, and generating prompt information based on the results.

Benefits of technology

Improves the efficiency and accuracy of command verification, reduces the possibility of command execution errors, enhances the accuracy of commands, and improves the friendliness of CLI operations, especially for complex commands, users can obtain immediate feedback and guidance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883370A_ABST
    Figure CN119883370A_ABST
Patent Text Reader

Abstract

The invention discloses a command verification method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a target command through an input interface, and extracting a target parameter and a parameter value of the target parameter from the target command; acquiring parameter data information; wherein the parameter data information comprises position information of each parameter, parameter types, parameter value information and any one or a combination of any more of relationships among different parameters, the parameter types comprise required parameters and non-required parameters, and the relationships among the different parameters comprise a binding relationship and a mutual exclusion relationship; and verifying the target parameter and the corresponding parameter value according to the parameter data information to generate a verification result of the target command. Through automatic parameter verification, the reliability of command execution is improved, and the operation efficiency of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a command verification method, device, electronic device, and storage medium. Background Art

[0002] CLI (Command Line Interface) is a visual prompt interface provided by a computer operating system or application to users. Users enter commands through input interfaces such as keyboards, and the computer executes them after receiving the commands. It is a simple and efficient interface.

[0003] Storage systems usually support CLI to set up, manage and maintain the system. With the continuous development of storage technology, the functions supported by storage systems are gradually increasing. Complex CLI commands and their options make user operations less friendly. The prompt information on the CLI interface is insufficient and lacks specificity, making it difficult for general users to analyze the causes of command execution errors.

[0004] In the related art, users can use help options to obtain command description information. For general users, it is impossible to accurately understand the command syntax only through general description information, and when the command is more complicated, it is too cumbersome to locate the problem from the description information.

[0005] Therefore, how to automatically verify the commands input by the user and improve the efficiency and accuracy of command verification is a technical problem that those skilled in the art need to solve. Summary of the invention

[0006] The purpose of the present application is to provide a command verification method, device and equipment, storage medium and computer program product, which realize automatic verification of commands input by users and improve the efficiency and accuracy of command verification.

[0007] To achieve the above purpose, the present application provides a command verification method, comprising:

[0008] Obtain a target command through an input interface, and extract a target parameter and a parameter value of the target parameter from the target command;

[0009] Obtain parameter data information; wherein the parameter data information includes any one or a combination of the position information of each parameter, parameter type, parameter value information, and the relationship between different parameters. The parameter type includes mandatory parameters and non-mandatory parameters. The relationship between different parameters includes binding relationship and mutually exclusive relationship.

[0010] The target parameters and corresponding parameter values ​​are verified according to the parameter data information to generate the verification result of the target command.

[0011] Among them, the target parameters and the corresponding parameter values ​​are verified according to the parameter data information to generate the verification result of the target command, including:

[0012] Determine the required parameters according to the parameter data information, and verify whether the extracted target parameters include all the required parameters to generate a first verification result;

[0013] Verifying whether there are mutually exclusive parameters in the extracted target parameters according to the parameter data information to generate a second verification result;

[0014] Determine, according to the parameter data information, binding parameters that have a binding relationship with each target parameter, and verify whether all binding parameters exist in the extracted target parameters to generate a third verification result;

[0015] Verifying the extracted parameter value of the target parameter according to the parameter data information to generate a fourth verification result;

[0016] A verification result of the target command is determined based on the first verification result, the second verification result, the third verification result, and the fourth verification result.

[0017] After the verification result of the target command is generated, the following is also included:

[0018] Determine error information existing in the target command according to the verification result of the target command, and generate prompt information based on the error information.

[0019] Among them, it also includes:

[0020] Generate parameter data information according to the command syntax diagram.

[0021] The parameter data information is generated according to the command syntax diagram, including:

[0022] Traverse the command syntax diagram line by line;

[0023] In the process of traversing the target line of the command syntax diagram, the parameters are read in the target line according to the parameter naming rule;

[0024] If the read first parameter is located on the main path line of the target row, the first parameter type is determined as a required parameter, the position information of the first parameter is recorded, and the parameter value information of the first parameter is continued to be read;

[0025] If the read second parameter is located on the secondary path line of the target row, the first target delimiter where the second parameter is located is determined in the secondary path line, and the second target delimiter with the same position as the first target delimiter is determined in the main path line, and it is determined whether there is a third parameter in the second target delimiter in the main path line. If so, the parameter type of the second parameter is determined as a required parameter, and the relationship between the second parameter and the third parameter is determined as a mutually exclusive relationship. The position information of the second parameter is recorded, and the parameter value information of the second parameter is continued to be read. If not, the parameter type of the second parameter is determined as a non-required parameter, the position information of the second parameter is recorded, and the parameter value information of the second parameter is continued to be read.

[0026] The relationship between multiple parameters within the same delimiter is determined as a binding relationship;

[0027] Parameter data information is generated based on the parameters read from all lines in the command syntax diagram, parameter position information, parameter type, parameter value information, and the relationship between different parameters.

[0028] The location information of the first parameter is recorded, including:

[0029] Record the position of the first character of the parameter name of the first parameter in the main path line as the position information of the first parameter;

[0030] Accordingly, the location information of the second parameter is recorded, including:

[0031] The position of the first character of the parameter name of the second parameter in the secondary path line is recorded as the position information of the second parameter.

[0032] The location information of the first parameter is recorded, including:

[0033] Record the position of the separator before the parameter name of the first parameter in the main path line as the position information of the first parameter;

[0034] Accordingly, the location information of the second parameter is recorded, including:

[0035] The position of the separator before the parameter name of the second parameter in the secondary path line is recorded as the position information of the second parameter.

[0036] To achieve the above objectives, the present application provides a command verification device, comprising:

[0037] An extraction module, used for obtaining a target command through an input interface, and extracting a target parameter and a parameter value of the target parameter from the target command;

[0038] An acquisition module is used to acquire parameter data information; wherein the parameter data information includes any one or a combination of the position information of each parameter, parameter type, parameter value information, and the relationship between different parameters, the parameter type includes mandatory parameters and non-mandatory parameters, and the relationship between different parameters includes binding relationship and mutually exclusive relationship;

[0039] The verification module is used to verify the target parameters and the corresponding parameter values ​​according to the parameter data information, and generate the verification result of the target command.

[0040] To achieve the above objectives, the present application provides an electronic device, including:

[0041] Memory for storing computer programs;

[0042] A processor is used to implement the steps of the above command verification method when executing a computer program.

[0043] To achieve the above objectives, the present application provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above command verification method are implemented.

[0044] To achieve the above objectives, the present application provides a computer program product, including a computer program, which implements the steps of the above command verification method when executed by a processor.

[0045] It can be seen from the above scheme that a command verification method provided by the present application includes: obtaining a target command through an input interface, extracting target parameters and parameter values ​​of target parameters in the target command; obtaining parameter data information; wherein the parameter data information includes the location information of each parameter, parameter type, parameter value information, and any one or a combination of several of the relationships between different parameters, the parameter type includes required parameters and non-required parameters, and the relationship between different parameters includes a binding relationship and a mutually exclusive relationship; verifying the target parameters and the corresponding parameter values ​​according to the parameter data information, and generating a verification result of the target command.

[0046] The command verification method provided by the present application automatically verifies the target command input through the input interface through pre-constructed parameter data information, and reduces the possibility of command execution errors and enhances the accuracy of the command by ensuring that all required parameters are included and the binding and mutual exclusion relationship between parameters are complied with. The verification result can enable the rapid identification and correction of problems in the target command. In addition, the present application can also improve the friendliness of command line operations, especially for complex commands, users can obtain immediate feedback and guidance, thereby reducing the difficulty of operation. It can be seen that the command verification method provided by the present application, through automated parameter verification, not only improves the reliability of command execution, but also optimizes the interaction process between the user and the command line interface, so that even complex CLI operations become simple and intuitive, greatly improving the user's operating efficiency. The present application also discloses a command verification device and an electronic device, a non-volatile storage medium and a computer program product, which can also achieve the above-mentioned technical effects.

[0047] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific implementation methods, they are used to explain the present disclosure, but do not constitute a limitation to the present disclosure. In the drawings:

[0049] Figure 1 is a flow chart of a command verification method according to an exemplary embodiment;

[0050] Figure 2 It is a flowchart of a method for generating parameter data information according to an exemplary embodiment;

[0051] Figure 3 is a structural diagram of a command verification device according to an exemplary embodiment;

[0052] Figure 4 The figure is a structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0053] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0054] The embodiment of the present application discloses a command verification method, which realizes automatic verification of commands input by a user and improves the efficiency and accuracy of command verification.

[0055] See also Figure 1 , a flowchart of a command verification method according to an exemplary embodiment is shown, such as Figure 1 As shown, including:

[0056] S101: Obtain a target command through an input interface, and extract a target parameter and a parameter value of the target parameter from the target command;

[0057] In this step, the target command input by the user is received through the input interface. The target command is the CLI operation that the user wants to perform, and the target command is parsed to extract key components, namely the target parameters and the parameter values ​​of these target parameters. Parameters are keywords used to control the command behavior in the command, and parameter values ​​are the specific setting values ​​of these parameters. For example, in a file operation command, the parameter may be "-filename", and the parameter value is the specific file name that the user wants to operate.

[0058] S102: Acquire parameter data information; wherein the parameter data information includes any one or a combination of the position information of each parameter, parameter type, parameter value information, and the relationship between different parameters, the parameter type includes mandatory parameters and non-mandatory parameters, and the relationship between different parameters includes binding relationship and mutually exclusive relationship;

[0059] In this step, pre-constructed parameter data information is obtained, and the parameter data information includes parameter location information, that is, the specific location of the parameter in the path line where it is located; parameter type, which is divided into mandatory parameters and non-mandatory parameters. Mandatory parameters are required to execute the command, while non-mandatory parameters can be selectively provided according to user needs; parameter value information, that is, the specific content and format of the parameter value; and the relationship between different parameters, including binding relationships between parameters, that is, some parameters must be used together, or mutually exclusive relationships, that is, some parameters cannot be used at the same time.

[0060] As a feasible implementation method, parameter data information is generated according to the command syntax diagram. In a specific implementation, parameter data information can be generated according to the command syntax diagram, that is, the command syntax diagram is used as an entry point to generate structured parameter data information. The command syntax diagram describes the structure and grammatical rules of the command in detail, by analyzing each element in the command syntax diagram, including the path line, command, parameter, parameter value / variable, the path line represents a complete CLI command, starting with a double arrow (>>) and ending with a reverse double arrow (><). When displayed across lines, the first line starts with a double arrow and ends with a single arrow (>), the middle lines all start and end with single arrows, and the last line starts with a single arrow and ends with a reverse double arrow. The command is located at the starting position of the main path line, and the style can be bold and regular, with spaces before and after. For example:

[0061] >>--mkuser---name--user_name----------------------------------><

[0062] Among them, "mkuser" is the command.

[0063] Parameters can be composed of a hyphen "-" and a parameter name. The style can be bold and regular, with spaces before and after. Parameters on the main path line are required. The main path line is the first path line in the row. For example:

[0064] >>--mkuser---name--user_name----------------------------------><

[0065] Among them, "-name" is a required parameter.

[0066] Optional parameters are located below the main path line (secondary path line) and enclosed by plus signs "+". For example:

[0067] >>--mkmdiskgrp---+---------------------------------+----------------><

[0068] +---name--pool_name------+

[0069] Among them, "-name" is a required parameter.

[0070] Parameters stacked vertically and enclosed in plus signs "+" are mutually exclusive.

[0071] Parameter values ​​and variables refer to passwords, file names, user names, etc. Parameter values ​​and variables are in italics with spaces before and after. For example:

[0072] >>--mkuser---name--user_name----------------------------------><

[0073] "user_name" is the parameter value of the "-name" parameter.

[0074] If a parameter has multiple parameter values ​​or variables, they are enclosed in plus signs "+" and stacked vertically. For example:

[0075] >>--cfgportip---node--+--node_name---+--------------------------><

[0076] +--node_id------+

[0077] Among them, "node_name" and "node_id" are the parameter values ​​of the parameter "-node".

[0078] If the parameter value is optional, put it below the parameter. For example:

[0079]

[0080] "cleartext_password" is the optional parameter value of the "-password" parameter.

[0081] By analyzing these elements in the command syntax diagram, the position information, parameter type, parameter value information, and the relationship between different parameters of each parameter can be extracted from the command syntax diagram, thereby constructing structured parameter data information.

[0082] S103: Verify the target parameters and corresponding parameter values ​​according to the parameter data information, and generate a verification result of the target command.

[0083] In this step, the target parameters and their parameter values ​​in the target command are verified according to the parameter data information. The verification process includes multiple aspects: first, verify whether all the required parameters have been provided, second, verify whether the binding relationship and mutual exclusion relationship between the parameters are satisfied, to ensure that the command entered by the user is logically reasonable, and further, verify whether the parameter value of the parameter conforms to the parameter value information. Finally, the verification result of the target command is generated based on these verification results, which may include prompt information on whether the command is valid, which parameters have problems, and how to correct these problems. The purpose of this step is to ensure that the command entered by the user is correct and complete before execution, thereby improving the success rate of command execution, and providing users with clear error feedback to help them quickly locate and correct input errors.

[0084] As a feasible implementation method, the target parameters and the corresponding parameter values ​​are verified according to the parameter data information to generate the verification result of the target command, including: determining the required parameters according to the parameter data information, and verifying whether the extracted target parameters contain all the required parameters to generate a first verification result; verifying whether there are mutually exclusive parameters in the extracted target parameters according to the parameter data information to generate a second verification result; determining the binding parameters that have a binding relationship with each target parameter according to the parameter data information, and verifying whether all the binding parameters exist in the extracted target parameters to generate a third verification result; verifying the parameter values ​​of the extracted target parameters according to the parameter data information to generate a fourth verification result; and determining the verification result of the target command based on the first verification result, the second verification result, the third verification result, and the fourth verification result.

[0085] In a specific implementation, first, determine which parameters are mandatory based on the parameter data information, and check whether all these mandatory parameters are included in the command input by the user, so as to generate a first verification result. Next, check whether there are mutually exclusive parameters in the target parameters, that is, parameters that cannot appear at the same time, to generate a second verification result. Then, determine other parameters that have a binding relationship with each target parameter, and check whether all these binding parameters are included in the input target command to generate a third verification result. In addition, the parameter value of the target parameter is verified according to the parameter data information to ensure that the parameter value of the target parameter conforms to the parameter value information of the target parameter to generate a fourth verification result. Finally, the overall verification result of the target command is determined by combining these four verification results, which may include detailed information on whether the command is valid, which parameters have problems, and how to correct these problems, providing users with clear feedback to help them quickly locate and correct input errors.

[0086] As a feasible implementation method, the parameter value information may include whether a parameter value exists. Accordingly, it is determined whether the target parameter has a parameter value based on the parameter value information. If the parameter value information shows that a parameter value exists, then it is checked whether the parameter value of the target parameter is extracted from the target command. If the parameter value of the target parameter is extracted from the target command, then the fourth verification result is that the verification passed. If the parameter value of the target parameter is not extracted from the target command, then the fourth verification result is that the verification failed.

[0087] As a preferred implementation, the parameter value information may also include the type and range of the parameter value. When verifying the parameter value of the target parameter, verify whether the parameter value of the target parameter extracted from the target command conforms to the type and range of the parameter value in the parameter value information to generate a fourth verification result. For example, if the parameter value of the target parameter is of a digital type, the value range of the parameter value of the target parameter is set in the parameter value information, and verify whether the parameter value of the target parameter extracted from the target command is of a digital type. If it is of a digital type, continue to verify whether the parameter value conforms to the value range specified in the parameter value information. If it conforms, the fourth verification result is verification passed. If it does not conform, the fourth verification result is verification failed. If it is not of a digital type, the fourth verification result is verification failed.

[0088] As a feasible implementation manner, after generating the verification result of the target command, it also includes: determining error information existing in the target command according to the verification result of the target command, and generating prompt information based on the error information.

[0089] In a specific implementation, after the verification result of the target command is generated, the verification result is further analyzed to identify specific errors in the command. According to the verification result, the missing required parameters, the existing mutually exclusive parameter conflicts, the missing binding parameters, and the errors or non-compliance of the parameter values ​​in the target command are determined. Based on these error messages, corresponding prompt messages are generated. These prompt messages are intended to clearly inform the user of the nature and location of the errors in the command and guide the user on how to correct these errors to ensure that the command can be executed correctly. This process improves the user-friendliness of the command line interface, helps users quickly understand and correct input errors, thereby improving the overall command execution efficiency and user experience.

[0090] The command verification method provided by the embodiment of the present application automatically verifies the target command input through the input interface through the pre-built parameter data information, and reduces the possibility of command execution errors by ensuring that all required parameters are included, and the binding and mutual exclusion relationship between parameters are complied with, thereby enhancing the accuracy of the command. The verification result can make it possible to quickly identify and correct problems in the target command. In addition, the embodiment of the present application can also improve the friendliness of command line operations, especially for complex commands, users can obtain immediate feedback and guidance, thereby reducing the difficulty of operation. It can be seen from this that the command verification method provided by the embodiment of the present application, through automated parameter verification, not only improves the reliability of command execution, but also optimizes the interaction process between the user and the command line interface, so that even complex CLI operations become simple and intuitive, greatly improving the user's operating efficiency.

[0091] The present application embodiment discloses a method for generating parameter data information, specifically:

[0092] See also Figure 2 , according to a flowchart of a method for generating parameter data information shown in an exemplary embodiment, such as Figure 2 As shown, including:

[0093] S201: traverse the command syntax diagram line by line;

[0094] In this embodiment, the purpose of line-by-line analysis of the command syntax diagram is to extract all parameters and related information that constitute the command from the syntax diagram. In the specific implementation, according to the layout of the command syntax diagram, it is read line by line, and the recording starts when the CLI command start symbol is read. The first string read is separated by spaces and plus signs as an instruction. For example:

[0095] >>--mkuser---name--user_name----------------------------------><;

[0096] Among them, "mkuser" is the command.

[0097] S202: in the process of traversing the target line of the command syntax diagram, reading parameters in the target line according to the parameter naming rule;

[0098] In this step, in the target row of the command syntax diagram currently traversed, the parameters are identified and read according to a preset parameter naming rule, and the parameter naming rule may be a dash "-" + parameter name.

[0099] S203: If the read first parameter is located on the main path line of the target row, determine the first parameter type as a required parameter, record the position information of the first parameter, and continue to read the parameter value information of the first parameter;

[0100] In a specific implementation, the parameters read on the main path line are mandatory parameters, and the main path line is the first path line in the target row. For example:

[0101] >>--mkuser---name--user_name----------------------------------><

[0102] Among them, "-name" is a required parameter.

[0103] When the first parameter is read in the main path line, the position information of the first parameter is recorded. As a feasible implementation, the position of the first character of the parameter name of the first parameter in the main path line is recorded as the position information of the first parameter. As another feasible implementation, the position of the separator before the parameter name of the first parameter in the main path line is recorded as the position information of the first parameter. Then, continue to read the parameter value information of the first parameter, including whether the parameter value exists or not. In the above example, the parameter value of the first parameter "-name" is "user_name", that is, the parameter value information of the first parameter "-name" is that the parameter value exists.

[0104] S204: If the read second parameter is located on the secondary path line of the target row, determine the first target delimiter where the second parameter is located in the secondary path line, determine the second target delimiter at the same position as the first target delimiter in the main path line, and determine whether there is a third parameter in the second target delimiter in the main path line. If so, determine the parameter type of the second parameter as a required parameter, determine the relationship between the second parameter and the third parameter as a mutually exclusive relationship, record the position information of the second parameter, and continue to read the parameter value information of the second parameter. If not, determine the parameter type of the second parameter as a non-required parameter, record the position information of the second parameter, and continue to read the parameter value information of the second parameter.

[0105] In a specific implementation, if the second parameter is read on a secondary path line (a path line other than the main path line), the first target separator ("+") where the second parameter is located is determined in the secondary path line, and the second target separator at the same position as the first target separator is determined in the main path line, and it is determined whether there is a third parameter in the second target separator in the main path line. If so, the parameter type of the second parameter is determined as a required parameter, and the second parameter and the third parameter are mutually exclusive parameters. If not, the second parameter is a non-required parameter.

[0106] Regardless of whether the second parameter is a required parameter or an optional parameter, the position information of the second parameter needs to be recorded. As a feasible implementation, the position of the first character of the parameter name of the second parameter in the secondary path line is recorded as the position information of the second parameter. As another feasible implementation, the position of the separator before the parameter name of the second parameter in the secondary path line is recorded as the position information of the second parameter. Then, the parameter value information of the second parameter is read, including whether the parameter value exists or not.

[0107] S205: determining the relationship between the multiple parameters located in the same delimiter as a binding relationship;

[0108] In this step, multiple parameters within the same separator ("+") are determined as binding parameters.

[0109] S206: Generate parameter data information based on the parameters read from all lines in the command syntax diagram, parameter location information, parameter type, parameter value information, and the relationship between different parameters.

[0110] In this step, all parameter information read from each line of the command syntax diagram is integrated, including parameter position information, parameter type, parameter value information, and the relationship between parameters, to generate complete parameter data information. In the parameter data information, parameters read from the same line of the command syntax diagram are divided into the same group, and parameters read from different lines of the command syntax diagram are divided into different groups. The parameter data information is used in the subsequent command verification process to ensure the correctness and validity of the command.

[0111] It can be seen that this embodiment generates parameter data information according to the command syntax diagram, generates structured parameter data information with the command syntax diagram as the entry point, and checks the target command input by the user, which can provide more targeted command line description information to help users quickly locate problems and improve the friendliness of command line operations. Through this embodiment, grammar rule generation and user input verification can be uniformly provided for all CLI commands with syntax diagrams, reducing repeated development of command line friendliness, reducing development costs, and improving CLI command reliability.

[0112] For example, the CLI command syntax diagram is as follows:

[0113]

[0114] The analysis process of the command syntax diagram is as follows: First, read the command line start symbol and read the first line to find the command name mkmdiskgrp. Continue reading until the next main path symbol to get the -name parameter position 17 and the -mdisk parameter position 52. Because the main path has no parameters at the corresponding position, it is an optional parameter. Read the second line of the main path to get the -ext required parameter position 3. Continue reading until the next main path to get the -size parameter position 3 and the -parentmdiskgrp parameter position 32. Because the -size and -parentmdiskgrp parameters are in the same plus sign range, they are parameters that must appear at the same time. Because the -size parameter and the main path -ext parameter position are the same, -ext and -size, -ext and -parentmdiskgrp are mutually exclusive parameters. Read the next group. The main path has no parameters. The next line reads the -warning parameter position 3. The next line reads the -unit parameter position 46. Because the corresponding position of -warning has no parameters and is an optional parameter, the corresponding position of -unit has no parameters and is in the same plus sign as -warning, so it is an optional parameter and can only appear in conjunction with warning. Read the start character of the next line. The main path has no parameters. The second line reads the parameter -intier position 3. Read -advance position 30 and there is no parameter value afterwards, which is marked as a parameter without value. The corresponding position of -intier has no parameter and is an optional parameter. The corresponding position of -advance has no parameter and is an optional parameter.

[0115] The storage method of parameter data information is shown in Table 1:

[0116] Table 1

[0117] parameter Location Optional Required Binding Parameter Value Grouping -name 17 yes no none have 0 -mdisk 52 yes no none have 0 -ext 3 no yes none have 1 -size 3 no yes -parentmdiskgrp have 1 -parentmdiskgrp 32 yes no -siZe have 1 -warning 3 yes no none have 2 -unit 46 yes no -warning have 2 -intier 3 yes no none have 3 -advance 30 yes no none none 3

[0118] Assume that the user input command is: "mkmdiskgrp-name testdisk-size 1024-ext 1024-unitkb-advance test". The user command line input is processed. First, the command mkmdiskgrp is formatted. The parameter -name value is testdisk, the parameter -size value is 1024, the parameter -ext value is 1024, the parameter -unit value is kb, and the parameter -advance value is test. Each group is traversed to determine whether the user input contains mandatory parameters. Group 0 has no mandatory parameters. Group 1 has two mutually exclusive mandatory parameters in the same position, and one of them must exist. Groups 2 and 3 have no mandatory parameters. Therefore, the user input -size-ext has a conflict. Traverse the user input parameters to check the parameter binding relationship. When the -size parameter appears, it should be accompanied by the -parentmdiskgrp parameter. When the -unit parameter appears, it should be accompanied by the -warning parameter. Finally, traverse the input parameters to check the function value. Among them, -advance should have no parameter value. Collect the above errors to generate prompt information for the user: the -ext parameter conflicts with the -size parameter, the -size parameter is missing -parentmdiskgrp, the -unit parameter is missing -warning, and the -advance parameter does not require a parameter value.

[0119] A command verification device provided in an embodiment of the present application is introduced below. The command verification device described below and the command verification method described above can be referenced to each other.

[0120] See also Figure 3 , a structural diagram of a command verification device according to an exemplary embodiment is shown, such as Figure 3 As shown, including:

[0121] The extraction module 100 is used to obtain a target command through an input interface, and extract a target parameter and a parameter value of the target parameter from the target command;

[0122] The acquisition module 200 is used to acquire parameter data information; wherein the parameter data information includes any one or a combination of the position information of each parameter, parameter type, parameter value information, and the relationship between different parameters, the parameter type includes mandatory parameters and non-mandatory parameters, and the relationship between different parameters includes a binding relationship and a mutually exclusive relationship;

[0123] The verification module 300 is used to verify the target parameters and the corresponding parameter values ​​according to the parameter data information, and generate the verification result of the target command.

[0124] The command verification device provided by the embodiment of the present application automatically verifies the target command input through the input interface through the pre-constructed parameter data information, and reduces the possibility of command execution errors and enhances the accuracy of the command by ensuring that all required parameters are included and the binding and mutual exclusion relationship between the parameters are complied with. The verification result can make it possible to quickly identify and correct problems in the target command. In addition, the embodiment of the present application can also improve the friendliness of command line operations, especially for complex commands, users can obtain immediate feedback and guidance, thereby reducing the difficulty of operation. It can be seen that the command verification device provided by the embodiment of the present application, through automated parameter verification, not only improves the reliability of command execution, but also optimizes the interaction process between the user and the command line interface, so that even complex CLI operations become simple and intuitive, greatly improving the user's operating efficiency.

[0125] On the basis of the above embodiments, as a preferred implementation mode, the verification module 300 is specifically used to: determine the required parameters according to the parameter data information, and verify whether the extracted target parameters contain all the required parameters to generate a first verification result; verify whether there are mutually exclusive parameters in the extracted target parameters according to the parameter data information to generate a second verification result; determine the binding parameters that have a binding relationship with each target parameter according to the parameter data information, and verify whether all binding parameters exist in the extracted target parameters to generate a third verification result; verify the parameter values ​​of the extracted target parameters according to the parameter data information to generate a fourth verification result; determine the verification result of the target command based on the first verification result, the second verification result, the third verification result, and the fourth verification result.

[0126] Based on the above embodiment, as a preferred implementation, it also includes:

[0127] The first generating module is used to determine error information existing in the target command according to the verification result of the target command, and generate prompt information based on the error information.

[0128] Based on the above embodiment, as a preferred implementation, it also includes:

[0129] The second generating module is used to generate parameter data information according to the command syntax diagram.

[0130] On the basis of the above embodiments, as a preferred implementation mode, the second generation module is specifically used for: traversing the command syntax diagram line by line; in the process of traversing the target line of the command syntax diagram, reading the parameters in the target line according to the parameter naming rules; if the first parameter read is located on the main path line of the target line, the first parameter type is determined as a required parameter, the position information of the first parameter is recorded, and the parameter value information of the first parameter is continued to be read; if the second parameter read is located on the secondary path line of the target line, the first target delimiter where the second parameter is located is determined in the secondary path line, the second target delimiter with the same position as the first target delimiter is determined in the main path line, and the first target delimiter in the main path line is determined. Whether there is a third parameter in the second target delimiter, if so, the parameter type of the second parameter is determined as a required parameter, the relationship between the second parameter and the third parameter is determined as a mutually exclusive relationship, the position information of the second parameter is recorded, and the parameter value information of the second parameter is continued to be read; if not, the parameter type of the second parameter is determined as a non-required parameter, the position information of the second parameter is recorded, and the parameter value information of the second parameter is continued to be read; the relationship between multiple parameters located in the same delimiter is determined as a binding relationship; parameter data information is generated based on the parameters read in all lines in the command syntax diagram, the position information of the parameters, the parameter type, the parameter value information, and the relationship between different parameters.

[0131] Based on the above embodiments, as a preferred implementation mode, the second generation module is specifically used to: record the position of the first character of the parameter name of the first parameter in the main path line as the position information of the first parameter; record the position of the first character of the parameter name of the second parameter in the secondary path line as the position information of the second parameter.

[0132] Based on the above embodiments, as a preferred implementation mode, the second generation module is specifically used to: record the position of the previous separator of the parameter name of the first parameter in the main path line as the position information of the first parameter; record the position of the previous separator of the parameter name of the second parameter in the secondary path line as the position information of the second parameter.

[0133] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0134] Based on the hardware implementation of the above program module, and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device, Figure 4 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 4 As shown, the electronic equipment includes:

[0135] Communication interface 1, capable of exchanging information with other devices such as network devices;

[0136] The processor 2 is connected to the communication interface 1 to realize information exchange with other devices and is used to execute the command verification method provided by one or more technical solutions when running the computer program. The computer program is stored in the memory 3.

[0137] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 4 Various buses are labeled as bus system 4.

[0138] The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0139] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 3 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.

[0140] The method disclosed in the above embodiment of the present application can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in the memory 3, and the processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.

[0141] When the processor 2 executes the program, the corresponding processes in each method of the embodiment of the present application are implemented, which will not be repeated here for the sake of brevity.

[0142] In an exemplary embodiment, the present application also provides a non-volatile storage medium storing a computer program, which can be executed by the processor 2 to complete the aforementioned method steps.

[0143] In an exemplary embodiment, the present application also provides a computer program product, including a computer program, which is executed by the processor 2 to complete the aforementioned method steps.

[0144] It can be understood by those of ordinary skill in the art that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to computer program instructions, and the aforementioned computer program can be stored in a non-volatile storage medium. When the computer program is executed, it executes the steps of the above-mentioned method embodiments. Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product, which is stored in a non-volatile storage medium and includes a number of instructions to enable an electronic device (which can be a personal computer, a server, a network device, etc.) to execute all or part of the methods of each embodiment of the present application.

[0145] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A command verification method, characterized in that: include: Acquire a target command through an input interface, and extract a target parameter and a parameter value of the target parameter from the target command; Obtain parameter data information; wherein the parameter data information includes any one or a combination of the position information of each parameter, parameter type, parameter value information, and the relationship between different parameters, the parameter type includes mandatory parameters and non-mandatory parameters, and the relationship between different parameters includes a binding relationship and a mutually exclusive relationship; The target parameters and corresponding parameter values ​​are verified according to the parameter data information to generate a verification result of the target command.

2. The command verification method according to claim 1, characterized in that: The verifying the target parameter and the corresponding parameter value according to the parameter data information to generate the verification result of the target command includes: Determine the required parameters according to the parameter data information, and verify whether the extracted target parameters include all the required parameters to generate a first verification result; Verify whether there are mutually exclusive parameters in the extracted target parameters according to the parameter data information to generate a second verification result; Determine binding parameters that have a binding relationship with each target parameter according to the parameter data information, and verify whether all the binding parameters exist in the extracted target parameters to generate a third verification result; Verifying the extracted parameter value of the target parameter according to the parameter data information to generate a fourth verification result; A verification result of the target command is determined based on the first verification result, the second verification result, the third verification result, and the fourth verification result.

3. The command verification method according to claim 2, characterized in that: After generating the verification result of the target command, the method further includes: Determine error information existing in the target command according to the verification result of the target command, and generate prompt information based on the error information.

4. The command verification method according to claim 1, characterized in that: Also includes: Generate parameter data information according to the command syntax diagram.

5. The command verification method according to claim 4, characterized in that: The generating of parameter data information according to the command syntax diagram includes: Traverse the command syntax diagram line by line; In the process of traversing the target line of the command syntax diagram, reading parameters in the target line according to the parameter naming rule; If the read first parameter is located on the main path line of the target row, the first parameter type is determined as a required parameter, the position information of the first parameter is recorded, and the parameter value information of the first parameter is continued to be read; If the read second parameter is located on the secondary path line of the target row, the first target delimiter where the second parameter is located is determined in the secondary path line, and the second target delimiter with the same position as the first target delimiter is determined in the main path line, and it is judged whether there is a third parameter in the second target delimiter in the main path line; if so, the parameter type of the second parameter is determined as a required parameter, the relationship between the second parameter and the third parameter is determined as a mutually exclusive relationship, the position information of the second parameter is recorded, and the parameter value information of the second parameter is continued to be read; if not, the parameter type of the second parameter is determined as a non-required parameter, the position information of the second parameter is recorded, and the parameter value information of the second parameter is continued to be read; The relationship between multiple parameters within the same delimiter is determined as a binding relationship; Parameter data information is generated based on the parameters read from all lines in the command syntax diagram, parameter position information, parameter type, parameter value information, and the relationship between different parameters.

6. The command verification method according to claim 5, characterized in that: The recording of the location information of the first parameter includes: Recording the position of the first character of the parameter name of the first parameter in the main path line as the position information of the first parameter; Correspondingly, the recording of the location information of the second parameter includes: The position of the first character of the parameter name of the second parameter in the secondary path line is recorded as the position information of the second parameter.

7. The command verification method according to claim 5, characterized in that: The recording of the location information of the first parameter includes: Recording the position of a separator before the parameter name of the first parameter in the main path line as the position information of the first parameter; Correspondingly, the recording of the location information of the second parameter includes: The position of a separator before the parameter name of the second parameter in the secondary path line is recorded as the position information of the second parameter.

8. A command verification device, characterized in that: include: An extraction module, used for acquiring a target command through an input interface, and extracting a target parameter and a parameter value of the target parameter from the target command; An acquisition module, used to acquire parameter data information; wherein the parameter data information includes any one or a combination of the position information of each parameter, parameter type, parameter value information, and the relationship between different parameters, wherein the parameter type includes mandatory parameters and non-mandatory parameters, and the relationship between different parameters includes a binding relationship and a mutually exclusive relationship; The verification module is used to verify the target parameters and corresponding parameter values ​​according to the parameter data information to generate a verification result of the target command.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the command verification method according to any one of claims 1 to 7 when executing the computer program.

10. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, and when the computer program is executed, the steps of the command verification method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Command line calibration method and device

    CN106775937A

  • Equipment control method and system, electronic equipment and storage medium

    CN112114876A

  • Parameter verification method, computer equipment and storage medium

    CN113535553A

  • Instruction analysis method and device and electronic equipment

    CN114064125A

  • Instruction Parsing Method and Apparatus, and Electronic Device

    US20240403051A1