A command verification method and device, electronic equipment and storage medium
By constructing parameter data information to automatically verify CLI commands, the system ensures that required parameters are included and that parameter relationships are correct. This solves the problem of unfriendly user operation caused by the complexity of the CLI interface, and achieves efficient and accurate command verification and user-friendly interaction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2024-12-30
- Publication Date
- 2026-04-14
AI Technical Summary
In the existing technology, the complex command instructions of the CLI interface make the operation unfriendly to users, and users have difficulty accurately understanding the command syntax and locating the cause of execution errors.
By constructing parameter data, the system automatically validates user-input commands, ensuring that required parameters are included, adhering to parameter binding and mutual exclusion relationships, generating validation results, and providing error messages.
It improves the efficiency and accuracy of command verification, reduces the possibility of execution errors, and enhances the user-friendliness and efficiency of operations.
Smart Images

Figure CN119883370B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a command verification method, apparatus, electronic device, and storage medium. Background Technology
[0002] CLI (Command Line Interface) is a visual prompt interface provided by a computer operating system or application to the user. The user enters commands through an input interface such as a keyboard, and the computer accepts and executes the commands. It is a simple and efficient interface.
[0003] Storage systems typically support CLI for setting up, managing, and maintaining the system. As storage technology continues to develop, the functions supported by storage systems are gradually increasing. The complex CLI commands and their options make the user operation less user-friendly. The CLI interface prompts are insufficient and lack specificity, making it difficult for general users to analyze the cause of command execution errors.
[0004] In related technologies, users can obtain command descriptions using help options. However, for general users, it is difficult to accurately understand command syntax using only general descriptions, and locating problems from descriptions is too cumbersome when commands are complex.
[0005] Therefore, how to automatically validate user-input commands and improve the efficiency and accuracy of command validation is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0006] The purpose of this application is to provide a command verification method, apparatus and device, storage medium and computer program product, which realizes automatic verification of user-input commands and improves the efficiency and accuracy of command verification.
[0007] To achieve the above objectives, this application provides a command verification method, including:
[0008] The target command is obtained through the input interface, and the target parameters and their values are extracted from the target command.
[0009] Obtain parameter data information; wherein, 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, parameter type includes required parameters and optional parameters, and the relationships between different parameters include binding relationships and mutual exclusion relationships;
[0010] The target parameters and their corresponding values are validated based on the parameter data information, and the validation results of the target command are generated.
[0011] This includes validating the target parameters and their corresponding values based on the parameter data information, and generating the validation results of the target command, including:
[0012] Based on the parameter data information, the required parameters are determined, and the extracted target parameters are verified to include all the required parameters in order to generate the first verification result.
[0013] The second verification result is generated by verifying whether there are mutually exclusive parameters among the extracted target parameters based on the parameter data information.
[0014] Based on the parameter data information, determine the binding parameters that are bound to each target parameter, and verify whether all the bound parameters exist among the extracted target parameters to generate a third verification result;
[0015] The extracted target parameter values are verified based on the parameter data information to generate a fourth verification result;
[0016] The 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 generating the verification result of the target command, the following is also included:
[0018] Based on the verification results of the target command, determine the error information present in the target command, and generate prompt information based on the error information.
[0019] This also includes:
[0020] Parameter data information is generated based on the command syntax diagram.
[0021] The parameter data information generated based on the command syntax graph includes:
[0022] Syntax diagram for line-by-line traversal commands;
[0023] During the traversal of the target line of the command syntax graph, parameters are read from the target line according to the parameter naming rules;
[0024] If the first parameter read is located on the main path of the target line, then the type of the first parameter is determined to be a required parameter, the position information of the first parameter is recorded, and the parameter value information of the first parameter is read.
[0025] If the second parameter read is located on the secondary path of the target line, then determine the first target separator where the second parameter is located in the secondary path, determine the second target separator in the main path that is in the same position as the first target separator, determine whether there is a third parameter in the second target separator in the main path, if there is, then 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 mutual exclusion relationship, record the position information of the second parameter, and continue to read the parameter value information of the second parameter; if there is no parameter, then 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.
[0026] Define the relationship between multiple parameters located within the same delimiter as a binding relationship;
[0027] Parameter data information is generated based on the parameters read from all lines in the command syntax graph, the parameter location 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 as the position information of the first parameter;
[0030] Accordingly, the location information of the second parameter is recorded, including:
[0031] Record the position of the first character of the parameter name of the second parameter in the secondary path 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 preceding the parameter name of the first parameter in the main path as the position information of the first parameter;
[0034] Accordingly, the location information of the second parameter is recorded, including:
[0035] Record the position of the separator preceding the parameter name of the second parameter in the secondary path as the position information of the second parameter.
[0036] To achieve the above objectives, this application provides a command verification device, comprising:
[0037] The extraction module is used to obtain the target command through the input interface, and extract the target parameters and the parameter values of the target parameters from the target command;
[0038] The acquisition module is used to acquire parameter data information. The parameter data information includes the location information of each parameter, the parameter type, the parameter value information, and any one or a combination of the relationships between different parameters. The parameter types include required parameters and optional parameters. The relationships between different parameters include binding relationships and mutual exclusion relationships.
[0039] The verification module is used to verify the target parameters and their corresponding values based on the parameter data information, and generate the verification results of the target command.
[0040] To achieve the above objectives, this application provides an electronic device, comprising:
[0041] Memory, used to store computer programs;
[0042] A processor is used to implement the steps of the command verification method described above when executing a computer program.
[0043] To achieve the above objectives, this application provides a non-volatile storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the command verification method described above.
[0044] To achieve the above objectives, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the command verification method described above.
[0045] As can be seen from the above scheme, the command verification method provided in this application includes: obtaining a target command through an input interface, extracting target parameters and parameter values from the target command; obtaining parameter data information; wherein, the parameter data information includes any one or a combination of any of the following: position information of each parameter, parameter type, parameter value information, and relationships between different parameters; the parameter type includes required parameters and non-required parameters; the relationships between different parameters include binding relationships and mutual exclusion relationships; verifying the target parameters and their corresponding parameter values based on the parameter data information, and generating a verification result for the target command.
[0046] The command verification method provided in this application automatically verifies the target command input through the input interface using pre-constructed parameter data. By ensuring that all required parameters are included and that the binding and mutual exclusion relationships between parameters are respected, the possibility of command execution errors is reduced, and the accuracy of the command is enhanced. The verification results allow for the rapid identification and correction of problems in the target command. Furthermore, this application improves the user-friendliness of command-line operations, especially for complex commands, providing users with immediate feedback and guidance, thereby reducing operational difficulty. Therefore, the command verification method provided in this application, through automated parameter verification, not only improves the reliability of command execution but also optimizes the user-command-line interface interaction process, making even complex CLI operations simple and intuitive, greatly improving user efficiency. This application also discloses a command verification device, an electronic device, a non-volatile storage medium, and a computer program product, which can achieve the same technical effects.
[0047] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. The drawings are used to provide a further understanding of this disclosure and constitute a part of the specification. They are used together with the following detailed description to explain this disclosure, but do not constitute a limitation of this disclosure. In the drawings:
[0049] Figure 1 This is a flowchart illustrating a command verification method according to an exemplary embodiment;
[0050] Figure 2 This is a flowchart illustrating a method for generating parameter data information according to an exemplary embodiment;
[0051] Figure 3 This is a structural diagram of a command verification device according to an exemplary embodiment;
[0052] Figure 4 This is a structural diagram of an electronic device according to an exemplary embodiment. Detailed Implementation
[0053] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Furthermore, in the embodiments of this application, "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0054] This application discloses a command verification method that enables automatic verification of user-input commands, thereby improving the efficiency and accuracy of command verification.
[0055] See Figure 1 A flowchart illustrating a command verification method according to an exemplary embodiment is shown below. Figure 1 As shown, it includes:
[0056] S101: Obtain the target command through the input interface, and extract the target parameters and parameter values from the target command;
[0057] In this step, the system receives the target command input by the user through the input interface. This target command is the CLI operation the user wishes to perform. The system parses the target command and extracts its key components: the target parameters and their values. Parameters are keywords in the command used to control command behavior, while parameter values are the specific settings of these parameters. For example, in a file operation command, the parameter might be "-filename", and the parameter value might be the specific filename the user wishes to operate on.
[0058] S102: Obtain 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 relationships between different parameters include binding relationships and mutual exclusion relationships;
[0059] In this step, pre-built parameter data information is obtained. The parameter data information includes the parameter location information, that is, the specific position of the parameter in its path; the parameter type, which is divided into required parameters and optional parameters. Required parameters are necessary to execute the command, while optional parameters can be provided selectively 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 the binding relationship between parameters, that is, some parameters must be used together, or the mutual exclusion relationship, that is, some parameters cannot be used at the same time.
[0060] As a feasible implementation method, parameter data information is generated based on the command syntax diagram. In specific implementation, parameter data information can be generated based on the command syntax diagram, that is, the command syntax diagram serves as the entry point for generating structured parameter data information. The command syntax diagram details the structure and syntax rules of the command. By analyzing each element in the command syntax diagram, including path lines, commands, parameters, and parameter values / variables, a 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 beginning of the main path line, and its style can be bold and upright, with spaces before and after it. For example:
[0061] >>--mkuser---name--user_name----------------------------------><
[0062] Among them, "mkuser" is the command.
[0063] Parameters can consist of a hyphen "-" and the parameter name, and can be in bold font with spaces before and after. Parameters located on the main path are required; the main path is the first path line in the line. For example:
[0064] >>--mkuser---name--user_name----------------------------------><
[0065] Among them, "-name" is a required parameter.
[0066] Parameters located below the main path (secondary path) and enclosed in plus signs "+" are optional. For example:
[0067] >>--mkmdiskgrp---+---------------------------------+----------------><
[0068] +---name--pool_name------+
[0069] Among them, "-name" is a required parameter.
[0070] Parameters that are stacked vertically and enclosed in plus signs "+" are mutually exclusive.
[0071] Parameter values and variables refer to passwords, filenames, usernames, etc. They are displayed in italics with spaces before and after them. For example:
[0072] >>--mkuser---name--user_name----------------------------------><
[0073] Here, "user_name" is the parameter value of "-name".
[0074] If a parameter has multiple values or variables, enclose them in plus signs "+" and stack them vertically. For example:
[0075] >>--cfgportip---node--+--node_name---+--------------------------><
[0076] +--node_id-----+
[0077] Among them, “node_name” and “node_id” are the parameter values of “-node”.
[0078] If the parameter value is optional, place it below the parameter. For example:
[0079] >>-chcurrentuser--+------------------------+------><
[0080] +---password---+--------------------------------+
[0081] +--cleartext_password--+
[0082] Here, "cleartext_password" is an optional parameter value for the "-password" parameter.
[0083] By analyzing these elements in the command syntax diagram, we can extract the position information, parameter type, parameter value information, and relationships between different parameters, thereby constructing structured parameter data information.
[0084] S103: Verify the target parameters and their corresponding values based on the parameter data information, and generate the verification result of the target command.
[0085] In this step, the target parameters and their values in the target command are validated based on the parameter data information. The validation process includes several aspects: First, it verifies whether all required parameters are provided; second, it verifies whether the binding and mutual exclusion relationships between parameters are satisfied to ensure that the user-input command is logically reasonable; further, it verifies whether the parameter values conform to the parameter value information; finally, based on these validation results, a validation result for the target command is generated, which may include 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 user-input command 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.
[0086] As a feasible implementation method, the target parameters and their corresponding parameter values are verified based on parameter data information to generate a verification result for the target command. This includes: determining mandatory parameters based on parameter data information, verifying whether the extracted target parameters contain all mandatory parameters to generate a first verification result; verifying whether there are mutually exclusive parameters among the extracted target parameters based on parameter data information to generate a second verification result; determining binding parameters that have a binding relationship with each target parameter based on parameter data information, verifying whether there are all binding parameters among the extracted target parameters to generate a third verification result; verifying the parameter values of the extracted target parameters based on parameter data information to generate a fourth verification result; and determining the verification result of the target command based on the first, second, third, and fourth verification results.
[0087] In practice, the process begins with the following steps: First, based on the parameter data, it's determined which parameters are mandatory, and the user-input command is checked to ensure all mandatory parameters are present, generating the first verification result. Next, it verifies whether there are mutually exclusive parameters among the target parameters—parameters that cannot appear simultaneously—generating the second verification result. Then, it identifies other parameters that are bound to each target parameter and verifies whether the input target command contains all bound parameters, generating the third verification result. Furthermore, the parameter values of the target parameters are validated based on the parameter data to ensure they conform to their specified value information, generating the fourth verification result. Finally, these four verification results are combined to determine the overall verification result of the target command. This may include detailed information on whether the command is valid, which parameters have issues, and how to correct these issues, providing clear feedback to the user and helping them quickly locate and correct input errors.
[0088] As a feasible implementation method, the parameter value information may include whether a parameter value exists. Accordingly, the existence of a target parameter is determined based on the parameter value information. If the parameter value information indicates that a parameter value exists, then the target command is checked to see if the target parameter value is extracted. If the target parameter value is extracted in the target command, then the fourth verification result is that the verification passes. If the target parameter value is not extracted in the target command, then the fourth verification result is that the verification fails.
[0089] In a preferred embodiment, the parameter value information may further include the type and range of the parameter value. When validating the parameter value of the target parameter, the system verifies whether the parameter value 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 a number, the system sets the value range of the target parameter in the parameter value information. The system verifies whether the parameter value extracted from the target command is a number. If it is a number, the system continues to verify whether the parameter value conforms to the value range specified in the parameter value information. If it does, the fourth verification result is "verification passed"; if it does not, the fourth verification result is "verification failed"; if it is not a number, the fourth verification result is "verification failed".
[0090] As a feasible implementation method, after generating the verification result of the target command, the method further includes: determining the error information existing in the target command based on the verification result of the target command, and generating prompt information based on the error information.
[0091] In practice, after generating the verification results of the target command, the results are further analyzed to identify specific errors in the command. Based on the verification results, issues such as missing required parameters, conflicting mutually exclusive parameters, missing bound parameters, and incorrect or non-compliant parameter values are identified. Based on this error information, corresponding prompts are generated. These prompts clearly inform the user of the nature and location of the errors in the command, guiding the user on how to correct them to ensure correct command execution. This process improves the user-friendliness of the command-line interface, helping users quickly understand and correct input errors, thereby improving overall command execution efficiency and user experience.
[0092] The command verification method provided in this application automatically verifies the target command input through the input interface using pre-constructed parameter data. By ensuring that all required parameters are included and that the binding and mutual exclusion relationships between parameters are respected, the possibility of command execution errors is reduced, and the accuracy of the command is enhanced. The verification results allow for the rapid identification and correction of problems in the target command. Furthermore, this application embodiment improves the user-friendliness of command-line operations, especially for complex commands, providing users with immediate feedback and guidance, thereby reducing operational difficulty. Therefore, the command verification method provided in this application embodiment, 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, making even complex CLI operations simple and intuitive, greatly improving user operational efficiency.
[0093] This application discloses a method for generating parameter data information, specifically:
[0094] See Figure 2 A flowchart illustrating a method for generating parameter data information according to an exemplary embodiment is shown below. Figure 2 As shown, it includes:
[0095] S201: Syntax diagram of line-by-line traversal commands;
[0096] In this embodiment, the purpose of line-by-line analysis of the command syntax graph is to extract all parameters constituting the command and their related information. In practice, the command syntax graph is read line by line according to its layout, and recording begins when the CLI command start symbol is encountered. The first string read, separated by a space and a plus sign, is the instruction. For example:
[0097] >>--mkuser---name--user_name----------------------------------><;
[0098] Among them, "mkuser" is the command.
[0099] S202: During the traversal of the target line of the command syntax graph, the parameters are read from the target line according to the parameter naming rules;
[0100] In this step, in the target line of the currently traversed command syntax graph, parameters are identified and read according to the preset parameter naming rules. The parameter naming rules can be a hyphen "-" followed by the parameter name.
[0101] S203: If the first parameter read is located on the main path of the target line, then the type of the first parameter is determined to be a required parameter, the position information of the first parameter is recorded, and the parameter value information of the first parameter is read again.
[0102] In practice, the parameters read on the main path are mandatory, and the main path is the first path in the target row. For example:
[0103] >>--mkuser---name--user_name----------------------------------><
[0104] Among them, "-name" is a required parameter.
[0105] When the first parameter is read in the main path, its position information is recorded. One possible implementation is to record the position of the first character of the parameter name in the main path. Another possible implementation is to record the position of the separator preceding the parameter name in the main path. Next, the parameter value information of the first parameter is read, including whether a parameter value exists or not. In the example above, the value of the first parameter "-name" is "user_name", meaning the parameter value of the first parameter "-name" exists.
[0106] S204: If the read second parameter is located on the secondary path of the target line, then determine the first target separator where the second parameter is located in the secondary path, determine the second target separator in the main path that is in the same position as the first target separator, determine whether there is a third parameter in the second target separator in the main path, if there is, then 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 mutual exclusion relationship, record the position information of the second parameter, and continue to read the parameter value information of the second parameter; if there is no parameter, then 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.
[0107] In practice, if a second parameter is read on a secondary path (a path other than the main path), the first target separator ("+") where the second parameter is located is determined in the secondary path, and a second target separator with the same position as the first target separator is determined in the main path. It is then determined whether a third parameter exists within the second target separator in the main path. If it exists, the parameter type of the second parameter is determined to be a required parameter, and the second parameter and the third parameter are mutually exclusive. If it does not exist, the second parameter is a non-required parameter.
[0108] Regardless of whether the second parameter is required or optional, its position information must be recorded. One feasible implementation is to record the position of the first character of the second parameter's name within the secondary path. Another feasible implementation is to record the position of the separator preceding the second parameter's name within the secondary path. Next, the parameter value information of the second parameter is read, including whether the parameter value exists or not.
[0109] S205: Define the relationship between multiple parameters located within the same delimiter as a binding relationship;
[0110] In this step, multiple parameters located within the same separator ("+") are identified as binding parameters.
[0111] S206: Generate parameter data information based on the parameters read from 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.
[0112] In this step, all parameter information read from each row of the command syntax graph is synthesized, including parameter location, type, value, and relationships between parameters, to generate complete parameter data. Parameters read from the same row of the command syntax graph are grouped into the same group, while parameters read from different rows are grouped into different groups. This parameter data is used in the subsequent command validation process to ensure the correctness and validity of the commands.
[0113] Therefore, this embodiment generates parameter data information based on the command syntax graph. By using the command syntax graph as a starting point to generate structured parameter data information, it can screen the target command input by the user and provide more targeted command-line explanation information, thereby helping users quickly locate problems and improving the user-friendliness of the command-line operation. This embodiment can uniformly provide syntax rule generation and user input validation for all CLI commands with syntax graphs, reducing redundant development of command-line friendliness, lowering development costs, and improving the reliability of CLI commands.
[0114] For example, the CLI command syntax diagram is as follows:
[0115] >>--mkmdiskgrp--+-----+-------------------------+->
[0116] +--name--pool_name-+--mdisk---+--mdisk_id_list---+
[0117] +mdisk_name_list+
[0118] >----+-ext--extent_size---------------------------------+----->
[0119] +---size--mdiskgrp_size---parentmdiskgrp--+--mdiskgrp_id----+
[0120] +-mdiskgrp_name-+
[0121] >----+---------------------+----------------------->
[0122] +---warning--+--disk_size-----+-------------------+
[0123] +-unit---+--b---+
[0124] +--kb-+
[0125] >----+------------------+----------------------------------><
[0126] +---intier--+--auto------+---advance--+
[0127] 十--on--------十
[0128] +--off--------+
[0129] The command syntax graph analysis process is as follows: First, read the command line start symbol and the first line to find the command name "mkmdiskgrp". Continue reading until the next main path symbol to find the -name parameter at position 17 and the -mdisk parameter at position 52. Since there are no parameters in the corresponding main path positions, they are optional parameters. Read the second main path to find the -ext parameter at position 3, which is mandatory. Continue reading until the next main path to find the -size parameter at position 3 and the -parentmdiskgrp parameter at position 32. Since the -size and -parentmdiskgrp parameters are in the same plus sign range, they must appear simultaneously. Because the -size parameter and the main path -ext parameter are in the same position, -ext and -size, and -ext and -parentmdiskgrp are mutually exclusive parameters. Read the next group; there are no parameters in the main path. The next line reads the -warning parameter at position 3 and the -unit parameter at position 46. Since there are no parameters in the -warning position, it is an optional parameter. The -unit position has no parameters and is in the same plus sign range as -warning, so it is also an optional parameter and can only appear when bound to warning. Read the start character of the next line. The main path has no parameters. Read the parameter -intier at position 3 in the second line. Read -advance at position 30. If there is no parameter value after it, mark it as a parameter with no value. The position corresponding to -intier has no parameter and is an optional parameter. The position corresponding to -advance has no parameter and is also an optional parameter.
[0130] The storage method for parameter data information is shown in Table 1:
[0131] Table 1
[0132] 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
[0133] Suppose the user input command is: "mkmdiskgrp -name testdisk -size 1024 -ext 1024 -unitkb -advance test". The user command-line input is processed first, formatted to obtain the command `mkmdiskgrp`, with the parameters `-name` set to `testdisk`, `-size` set to `1024`, `-ext` set to `1024`, `-unit` set to `kb`, and `-advance` set to `test`. Each group is iterated through to check if the user input contains required parameters. Group 0 has no required parameters; Group 1 has two mutually exclusive required parameters in the same position, one of which must be present; Groups 2 and 3 have no required parameters, therefore the user input `-size -ext` conflicts. The parameter binding relationships are checked during the iteration of the user input parameters. The `-size` parameter should be accompanied by `-parent mdiskgrp`, and the `-unit` parameter should be accompanied by `-warning`. Finally, the function values are checked during the iteration of the input parameters, where `-advance` should have no parameter value. Collect the above errors and generate prompts for the user: -ext parameter conflicts with -size parameter, -size parameter is missing -parentmdiskgrp, -unit parameter is missing -warning, -advance parameter does not need a value.
[0134] The following describes a command verification device provided in an embodiment of this application. The command verification device described below and the command verification method described above can be referred to each other.
[0135] See Figure 3 A structural diagram of a command verification device is shown according to an exemplary embodiment, such as... Figure 3 As shown, it includes:
[0136] Extraction module 100 is used to obtain target commands through input interface and extract target parameters and parameter values from the target commands;
[0137] The acquisition module 200 is used to acquire 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 relationships between different parameters include binding relationships and mutual exclusion relationships;
[0138] The verification module 300 is used to verify the target parameters and their corresponding values based on the parameter data information, and generate the verification result of the target command.
[0139] The command verification device provided in this application automatically verifies the target command input through the input interface using pre-built parameter data. By ensuring that all required parameters are included and that the binding and mutual exclusion relationships between parameters are respected, the possibility of command execution errors is reduced, and the accuracy of the command is enhanced. The verification results allow for the rapid identification and correction of problems in the target command. Furthermore, this application embodiment improves the user-friendliness of command-line operations, especially for complex commands, providing users with immediate feedback and guidance, thereby reducing operational difficulty. Therefore, the command verification device provided in this application embodiment, 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, making even complex CLI operations simple and intuitive, greatly improving user operational efficiency.
[0140] Based on the above embodiments, as a preferred implementation, the verification module 300 is specifically used for: determining mandatory parameters according to parameter data information, verifying whether the extracted target parameters include all mandatory parameters, to generate a first verification result; verifying whether there are mutually exclusive parameters among the extracted target parameters according to parameter data information, to generate a second verification result; determining binding parameters that have a binding relationship with each target parameter according to parameter data information, verifying whether there are all binding parameters among the extracted target parameters, to generate a third verification result; verifying the parameter values of the extracted target parameters according to 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.
[0141] Based on the above embodiments, as a preferred embodiment, it further includes:
[0142] The first generation module is used to determine the error information of the target command based on the verification result of the target command, and generate prompt information based on the error information.
[0143] Based on the above embodiments, as a preferred embodiment, it further includes:
[0144] The second generation module is used to generate parameter data information based on the command syntax graph.
[0145] Based on the above embodiments, as a preferred implementation, the second generation module is specifically used for: traversing the command syntax graph line by line; during the traversal of the target line of the command syntax graph, reading parameters in the target line according to the parameter naming rules; if the first parameter read is located on the main path of the target line, then 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 of the target line, then the first target separator where the second parameter is located is determined in the secondary path, and the second target separator with the same position as the first target separator is determined in the main path, and the main path is judged to be in the target line. If a third parameter exists within the second target delimiter, then the parameter type of the second parameter is determined to be a required parameter, the relationship between the second and third parameters is determined to be mutually exclusive, the position information of the second parameter is recorded, and the parameter value information of the second parameter continues to be read. If the third parameter does not exist, then the parameter type of the second parameter is determined to be a optional parameter, the position information of the second parameter is recorded, and the parameter value information of the second parameter continues to be read. The relationship between multiple parameters located within the same delimiter is determined to be a binding relationship. Parameter data information is generated based on the parameters read from all lines in the command syntax graph, the parameter position information, parameter type, parameter value information, and the relationship between different parameters.
[0146] Based on the above embodiments, as a preferred implementation, 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 as the position information of the first parameter; and record the position of the first character of the parameter name of the second parameter in the secondary path as the position information of the second parameter.
[0147] Based on the above embodiments, as a preferred implementation, the second generation module is specifically used to: record the position of the separator before the parameter name of the first parameter in the main path as the position information of the first parameter; and record the position of the separator before the parameter name of the second parameter in the secondary path as the position information of the second parameter.
[0148] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0149] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 4 This is a structural diagram of an electronic device according to an exemplary embodiment, such as... Figure 4 As shown, the electronic device includes:
[0150] Communication interface 1 enables information exchange with other devices, such as network devices;
[0151] Processor 2 is connected to communication interface 1 to enable information exchange with other devices and to execute the command verification methods provided by one or more of the above-mentioned technical solutions when running computer programs. The computer program is stored on memory 3.
[0152] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 4 The general will label all buses as Bus System 4.
[0153] The memory 3 in this embodiment 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.
[0154] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but 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), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0155] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. 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 integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in combination with its hardware.
[0156] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.
[0157] In an exemplary embodiment, this application also provides a non-volatile storage medium storing a computer program that can be executed by a processor 2 to complete the aforementioned method steps.
[0158] In an exemplary embodiment, this application also provides a computer program product, including a computer program that is executed by a processor 2 to perform the aforementioned method steps.
[0159] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to computer program instructions. The aforementioned computer program can be stored in a non-volatile storage medium, and when executed, it performs the steps of the above method embodiments. Alternatively, if the integrated units of this application are implemented as software functional modules and sold or used as independent products, they can also be stored in a non-volatile storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a non-volatile storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, network device, etc.) to execute all or part of the methods of the various embodiments of this application.
[0160] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A command verification method, characterized in that, include: The target command is obtained through the input interface, and the target parameters and their values are extracted from the target command. Obtain parameter data information; wherein, the parameter data information includes any one or a combination of several of the following: the location information of each parameter, the parameter type, the parameter value information, and the relationship between different parameters; the parameter type includes required parameters and optional parameters; the relationship between different parameters includes binding relationship and mutual exclusion relationship. The target parameters and their corresponding values are verified based on the parameter data information to generate the verification result of the target command; The method further includes: Syntax diagram for line-by-line traversal commands; During the traversal of the target lines of the command syntax graph, parameters are read from the target lines according to the parameter naming rules; If the first parameter read is located on the main path of the target line, then the first parameter type is determined to be a required parameter, the position information of the first parameter is recorded, and the parameter value information of the first parameter is read again. If the second parameter read is located on the secondary path of the target line, then the first target separator where the second parameter is located is determined in the secondary path, and the second target separator with the same position as the first target separator is determined in the main path. It is then determined whether there is a third parameter in the second target separator in the main path. If there is, the parameter type of the second parameter is determined to be a required parameter, the relationship between the second parameter and the third parameter is determined to be a mutual exclusion 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 there is no parameter, the parameter type of the second parameter is determined to be 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. Define the relationship between multiple parameters located within the same delimiter as a binding relationship; Parameter data information is generated based on the parameters read from all lines in the command syntax diagram, the parameter location information, parameter type, parameter value information, and the relationship between different parameters.
2. The command verification method according to claim 1, characterized in that, The step of verifying the target parameters and their corresponding values based on the parameter data information, and generating a verification result for the target command, includes: Based on the parameter data information, the required parameters are determined, and the extracted target parameters are verified to include all the required parameters in order to generate a first verification result. The second verification result is generated by verifying whether there are mutually exclusive parameters among the extracted target parameters based on the parameter data information. Based on the parameter data information, determine the binding parameters that are bound to each target parameter, and verify whether all the binding parameters exist among the extracted target parameters to generate a third verification result; The extracted target parameter values are verified based on the parameter data information to generate a fourth verification result; The 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: Based on the verification result of the target command, the error information existing in the target command is determined, and a prompt message is generated based on the error information.
4. The command verification method according to claim 1, characterized in that, The recording of the location information of the first parameter includes: Record the position of the first character of the parameter name of the first parameter in the main path as the position information of the first parameter; Accordingly, 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 is recorded as the position information of the second parameter.
5. The command verification method according to claim 1, characterized in that, The recording of the location information of the first parameter includes: Record the position of the separator preceding the parameter name of the first parameter in the main path as the position information of the first parameter; Accordingly, the recording of the location information of the second parameter includes: Record the position of the separator preceding the parameter name of the second parameter in the sub-path as the position information of the second parameter.
6. A command verification device, characterized in that, include: The extraction module is used to obtain a target command through an input interface, and extract target parameters and parameter values from the target command. The acquisition module is used to acquire parameter data information; wherein, the parameter data information includes any one or a combination of any of the following: the location information of each parameter, the parameter type, the parameter value information, and the relationship between different parameters; the parameter type includes required parameters and optional parameters; and the relationship between different parameters includes binding relationship and mutual exclusion relationship. The verification module is used to verify the target parameters and their corresponding values based on the parameter data information, and generate the verification result of the target command. The device further includes: The second generation module is used to traverse the command syntax graph line by line. During the traversal of the target line of the command syntax graph, parameters are read from the target line according to the parameter naming rules. If the first parameter read is located on the main path of the target line, its type is determined to be a required parameter, its position information is recorded, and its value information is read. If the second parameter read is located on the secondary path of the target line, the first target separator where the second parameter is located is determined in the secondary path, and the second target separator in the main path with the same position as the first target separator is determined. It is then determined whether the second target separator in the main path exists. If the third parameter exists, the parameter type of the second parameter is determined to be a required parameter, the relationship between the second parameter and the third parameter is determined to be mutually exclusive, the position information of the second parameter is recorded, and the parameter value information of the second parameter is read. If the third parameter does not exist, the parameter type of the second parameter is determined to be a optional parameter, the position information of the second parameter is recorded, and the parameter value information of the second parameter is read. The relationship between multiple parameters located within the same delimiter is determined to be a binding relationship. Parameter data information is generated based on the parameters read from all lines in the command syntax diagram, the parameter position information, parameter type, parameter value information, and the relationship between different parameters.
7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to perform the steps of the command verification method as described in any one of claims 1 to 5 when executing the computer program.
8. A non-volatile storage medium, characterized in that, The non-volatile storage medium stores a computer program, which, when executed, implements the steps of the command verification method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Command line calibration method and device
CN106775937A
Equipment control method and system, electronic equipment and storage medium
CN112114876A