Crates.io | properties-file-parser |
lib.rs | properties-file-parser |
version | 0.1.4 |
source | src |
created_at | 2024-11-12 13:19:28.635408 |
updated_at | 2024-11-16 17:19:31.179453 |
description | This is a project for .properties file parsing (https://en.wikipedia.org/wiki/.properties) |
homepage | |
repository | |
max_upload_size | |
id | 1444925 |
size | 41,551 |
This is a project for .properties file parsing (https://en.wikipedia.org/wiki/.properties)
This project is uploaded on crates.io:
https://crates.io/crates/properties-file-parser
.properties is a file extension used by Java technologies.
This extension is similar to .ini
Example of syntax:
name="John"
familyName="Smith"
# Age in years
age="35"
In property age="35", for example, age is property key, "35" is value.
# Age in years is comment.
Instead of =, you can also use : or empty space in property:
name: "John"
familyName "Smith"
Keys can have no value:
familyName
Comments can also start with !:
! Age in years
Tabs and spaces at the beginning of line or between key and value are ignored, so this syntax is also viable:
name = "John"
familyName="Smith"
# Age in years
age= "35"
This project's main purpose is to allow Rust users to parse .properties and use the results in their own code.
The project structure is following:
File which includes all pest grammar
Contains the code to parse .properties
It has methods parse_properties and parse_properties_as_string to parse
string as a vector of properties as Rust structure and convert it to readable format
Contains the code for CLI. The commands are following:
parse [INPUT_FILE_NAME]
// parses the contents of .properties file and shows readable result
parse [INPUT_FILE_NAME] [OUTPUT_FILE_NAME]
// parses the contents of .properties file and stores the readable result in file
help
// shows help
Contains the tests for the grammar
This project is created with pest crate. The pest grammar is following:
Parses comment, which can start with # or !
One or more spaces or tabs
property, such as:
key=value
key:value
key value
key
key in property
value in property
parses the whole file .properties
used in order not to get "EOI" in output