Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Ponyboy47/ConfigParser
A pure-Swift INI Config parser
https://github.com/Ponyboy47/ConfigParser
configparser ini ini-parser spm swift swift-package-manager
Last synced: about 1 month ago
JSON representation
A pure-Swift INI Config parser
- Host: GitHub
- URL: https://github.com/Ponyboy47/ConfigParser
- Owner: Ponyboy47
- License: mit
- Created: 2019-01-28T00:44:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-12T00:38:13.000Z (about 5 years ago)
- Last Synced: 2024-10-30T14:44:56.525Z (2 months ago)
- Topics: configparser, ini, ini-parser, spm, swift, swift-package-manager
- Language: Swift
- Size: 35.2 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ConfigParser
A pure-Swift implementation of the INI config parser
## Installation
### Swift Package Manager
```swift
.package(url: "https://github.com/Ponyboy47/ConfigParser.git", from: "0.4.0")
```## Usage
```swift
import ConfigParserlet confString = """
[section1]
key1 = value1
key2 = 1, 2, 3, 4[section2]
key1 = test
key2 = 1234
"""let config = try ConfigParser.parse(confString)
// Use subscripts to get the value you want in the type you want
let key1s1: String? = config[section: "section1", key: "key1"] // Optional(value1)
let key2s1 = config[section: "section2", key: "key1", default: [4, 3, 2, 1]] // [1, 2, 3, 4]
```
Supported Types:
- String
- Bool
- Int (8,16,32,64 and all the UInt variants)
- Double
- Float and Float80
- Arrays of any of the above types## TODO
- [ ] Section/Key name validation (must start with an alphabet character)
- [x] Retrieve values as specified type
- [x] Bool
- [x] String (default)
- [x] Double/Float
- [x] Int
- [x] Array
- [x] Write config to file
- [ ] Escape sequences (bug fix)
- [ ] Multi-line values
- [x] Read from string
- [ ] Customizable options
- [ ] Delimeter (ie: ':' instead of '=')
- [ ] Don't trim whitespace
- [ ] Nested sections
- [ ] Dotted section titles
- [ ] Indented sections
- [ ] Duplicate key behavior
- [ ] Keep first
- [ ] Overwrite
- [ ] Error## License
MIT