All Projects → salaros → config-parser

salaros / config-parser

Licence: MIT License
A slim, fully managed C# library for reading/writing .ini, .conf, .cfg etc configuration files.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to config-parser

i3
Archivos de configuraciones de i3
Stars: ✭ 32 (-52.24%)
Mutual labels:  config, configs, configuration-file, configuration-files, conf
libconfini
Yet another INI parser
Stars: ✭ 106 (+58.21%)
Mutual labels:  config, configuration, ini, configuration-file, conf
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+28.36%)
Mutual labels:  config, configuration, ini, configuration-file, configuration-files
Ini Parser
Read/Write an INI file the easy way!
Stars: ✭ 643 (+859.7%)
Mutual labels:  config, mono, configuration, ini
neovim-config
Modern NeoVim config for IDE-like development
Stars: ✭ 89 (+32.84%)
Mutual labels:  config, configuration, configuration-files
goconfig
.gitconfig syntax parser
Stars: ✭ 15 (-77.61%)
Mutual labels:  config, configuration, cfg
Gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections
Stars: ✭ 146 (+117.91%)
Mutual labels:  config, configuration, ini
awesome-pro
Awesome WM 4.x themes configs
Stars: ✭ 91 (+35.82%)
Mutual labels:  configs, configuration, configuration-files
ApexConfigs
Apex Legends configs for a competitve player
Stars: ✭ 52 (-22.39%)
Mutual labels:  config, configs, cfg
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-70.15%)
Mutual labels:  config, configuration, configuration-files
Slim-Config
A file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses https://github.com/hassankhan/config.
Stars: ✭ 28 (-58.21%)
Mutual labels:  config, ini
spdlog setup
spdlog setup initialization via file configuration for convenience.
Stars: ✭ 68 (+1.49%)
Mutual labels:  config, configuration
initool
Manipulate INI files from the command line
Stars: ✭ 40 (-40.3%)
Mutual labels:  ini, configuration-file
profig
Powerful configuration management for Scala (JSON, properties, command-line arguments, and environment variables)
Stars: ✭ 25 (-62.69%)
Mutual labels:  config, configuration
tomlj
A Java parser for Tom's Obvious, Minimal Language (TOML).
Stars: ✭ 72 (+7.46%)
Mutual labels:  config, configuration
eslint-define-config
Provide a defineConfig function for .eslintrc.js files
Stars: ✭ 61 (-8.96%)
Mutual labels:  config, configuration
dotfiles
My personal app/env configs and dotfiles.
Stars: ✭ 27 (-59.7%)
Mutual labels:  config, configuration
Machfiles
The dotfiles you see in all my videos
Stars: ✭ 347 (+417.91%)
Mutual labels:  config, configuration
ha-config-ataraxis
My Home Assistant Configs. If you like what you see, please ⭐️my repo. It would encourage me a lot 🤘
Stars: ✭ 146 (+117.91%)
Mutual labels:  config, configuration
goconf
Configuration loader in Go
Stars: ✭ 23 (-65.67%)
Mutual labels:  config, configuration-files

ConfigParser Build status AppVeyor tests branch Coverage Status

GitHub top language .NET Standard .NET Standard .NET Framework

License NuGet NuGet Pre Release NuGet

Donate Patreon Donate Paypal Donate Liberapay

ConfigParser - is a slim, cross-platform, fully managed C# library for reading and writing .ini, .conf, .cfg etc configuration files.

You could use it in your Unity 3D, Xamarin (iOS & Android), .NET Framework applications (even with old 4.0/4.5), .NET Core CLI and ASP.NET Core applications, Mono etc

Features

Customization

  • customizable encoding (most encodings can be auto-detected)
  • customizable culture
  • customizable number styles (e.g. currencies, exponential notation etc)
  • customizable line endings (usually auto-detected)
  • customizable true and false (e.g. "verum" / "falsum" )
  • customizable comment characters
  • customizable key/value separator (defaults to '=')

Read and preserved

  • file header comments
  • config files with no sections (like in this [SectionName]) or even mixed: first section has no header, just keys
  • comments in general
  • section comments
  • empty lines
  • indented sections
  • indented keys
  • indented values

Values

  • default values
  • multi-line values (both quoted and not)
  • quoted values
  • null values (value-less keys)
  • array values
  • fancy float / double
  • byte-encoded values
  • smart boolean values (0/1, on/off, enabled/disabled work of the box)

and more...

🟊🟊🟊 Support this project 🟊🟊🟊

You can support us in a small way, please consider starring and sharing this repo! It helps us getting known and grow the community.

star us

Installation

Config Parser can be installed via NuGet by using Package Manager in your IDE, dotnet binary or Package Console

# Add the Salaros.ConfigParser package to a project named [<PROJECT>]
dotnet add [<PROJECT>] package Salaros.ConfigParser

or Visual Studio's Package Console

# Add the Salaros.ConfigParser package to the default project
Install-Package Salaros.ConfigParser

# Add the Salaros.ConfigParser package to a project named [<PROJECT>]
Install-Package Salaros.ConfigParser -ProjectName [<PROJECT>]

Usage

// Initialize config file instance from file
var configFileFromPath = new ConfigParser(@"path\to\configfile.cnf");

// Parse text
var configFileFromString = new ConfigParser(@"
    [Strings]
        canBeIndented = value
    andQuoted = ""quotes will be stripped""

    [Numbers]
    withD = 0.6D
    dollars = $2,999

    [boolean]
    numericTrue = 1
    textFalse = true
    yesWorks = yes
    upperCaseWorks = on
    worksAsWell = Enabled

    [Advanced]
    arrayWorkToo =
        arrayElement1
        arrayElement2
    valueLessKey",
    new ConfigParserSettings
    {
        MultiLineValues = MultiLineValues.Simple | MultiLineValues.AllowValuelessKeys | MultiLineValues.QuoteDelimitedValues,
        Culture = new CultureInfo("en-US")
    }
);

configFileFromString.GetValue("Strings", "canBeIndented");          // value
configFileFromString["Strings"]["canBeIndented"];                   // returns 'value' too
configFileFromString.GetValue("Strings", "andQuoted");              // quotes will be stripped

configFileFromString.GetValue("Numbers", "withD", 0D);              // 0,6
configFileFromString.GetValue("Numbers", "dollars", 0D,             // 2999
    NumberStyles.AllowCurrencySymbol);
configFileFromString.GetValue("Numbers", "dollars");                // $2,999

configFileFromString.GetValue("boolean", "numericTrue", false);     // True
configFileFromString.GetValue("boolean", "textFalse", false);       // True
configFileFromString.GetValue("boolean", "yesWorks", false);        // True
configFileFromString.GetValue("boolean", "upperCaseWorks", false);  // True
configFileFromString.GetValue("boolean", "worksAsWell", false);     // True

configFileFromString.GetArrayValue("Advanced", "arraysWorkToo");     // ["arrayElement1","arrayElement2"]
configFileFromString.GetValue("Advanced", "valueLessKey");          //

How to build

You need Git and .NET Core SDK

git clone https://github.com/salaros/ConfigParser
cd ConfigParser
dotnet build

How to test

ConfigParser uses xUnit.net, so you can run unit tests by simply using the following command:

dotnet test tests

License

ConfigParser is distributed under the MIT license, which grants you

  • Private use
  • Commercial use
  • Modification
  • Distribution

However you have to include the content of license file in your source code (if you distribute your Software in text form), otherwise include it in your own LICENSE file or to some sort of About -> Open-source libraries section if you distribute your Software as a compiled library / binary. Here is why (part of MIT license):

The above copyright notice and this permission notice 
shall be included in all copies or substantial portions of the Software.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].