Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option for array handling for ini files #77

Closed
wants to merge 7 commits into from

Conversation

sthuber90
Copy link

Fixes #52 and fixes #56.

Handling systemd-networkd .network files is now outputting working files for network configuration.

Example of a eth0.network file

[Match]
Name=eth0

[Network]
Address=192.168.1.75/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4

The file is now parsed to following object:

{
  "Match": {
    "Name": "eth0"
  },
  "Network": {
    "Address": "192.168.1.75/24",
    "Gateway": "192.168.1.1",
    "DNS": [
      "8.8.8.8",
      "8.8.4.4"
    ]
  }
}

Through the isArray option one can define the output structure after encoding / stringifying

ini.stringify(parsed, { isArray: false})
# Output: "[Match]\nName=eth0\n\n[Network]\nAddress=192.168.1.75/24\nGateway=192.168.1.1\nDNS=8.8.8.8\nDNS=8.8.4.4\n"

ini.stringify(parsed, { isArray: true})
# or
ini.stringify(parsed)
# This output cannot be understood by systemd-networkd!
# Output: "[Match]\nName=eth0\n\n[Network]\nAddress=192.168.1.75/24\nGateway=192.168.1.1\nDNS[]=8.8.8.8\nDNS[]=8.8.4.4\n"

@sthuber90
Copy link
Author

As it seems that the project is not maintained anymore, I'll close this PR 😢

@sthuber90 sthuber90 closed this Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiple keys are not parsed Incorrect conversion of arrays to .ini format in Windows
1 participant