This project is a Rust application that processes and sorts YAML files based on specific configurations.
- Sorting YAML Arrays: Sorts arrays in YAML files based on a specified key.
- Sorting YAML Hashes: Sorts hashes in YAML files based on a predefined order and sorts remaining keys alphabetically.
- Configurable: Uses a
config.yamlfile for customizable sorting rules.
To build and install the project, run the following command:
cargo build --releaseThe executable will be located in the target/release directory.
The application is run via the command line with the following syntax:
cargo run -- <action> <path><action>: The action to perform. For example,ifor in-place processing.<path>: The path to the YAML file to process.
Example:
cargo run -- i example.yamlThe application uses a configuration file named config.yaml. The configuration file should be placed in the root directory of the project. This file specifies the order in which keys should be sorted and the key used for sorting arrays.
Example config.yaml:
preOrder:
- key1
- key2
sortKey: key_nameGiven the following example.yaml:
- age: 35
name: Carol
- age: 30
name: Alice
- age: 25
name: BobRunning the application with:
cargo run -- i example.yamlAnd a config.yaml:
preOrder:
- name
- age
sortKey: nameWill produce the following sorted example.yaml:
- name: Alice
age: 30
- name: Bob
age: 25
- name: Carol
age: 35To run the tests, use the following command:
cargo test- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.