{"id":6265,"library":"toml-cli","title":"TOML CLI","description":"toml-cli is a command-line interface tool designed for reading and writing keys and values within TOML configuration files. It is particularly useful for scripting and automating modifications to TOML files without requiring a full text editor. The library is currently at version 0.8.2 and appears to have an active release cadence.","status":"active","version":"0.8.2","language":"en","source_language":"en","source_url":"https://github.com/mrijken/toml-cli","tags":["toml","cli","configuration","automation"],"install":[{"cmd":"pip install toml-cli","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Requires Python 3.10 or higher.","package":"python","optional":false}],"imports":[],"quickstart":{"code":"import subprocess\nimport os\n\n# Create a dummy TOML file for demonstration\ntoml_content = \"\"\"\n[tool.poetry]\nname = \"my-project\"\nversion = \"0.1.0\"\nauthors = [\"John Doe <john.doe@example.com>\"]\n\n[database]\nhost = \"localhost\"\nport = 5432\n\"\"\"\nwith open(\"test.toml\", \"w\") as f:\n    f.write(toml_content)\n\nprint(\"Original TOML content:\")\nprint(toml_content)\n\n# Get a value\nprint(\"\\nGetting tool.poetry.name:\")\nresult = subprocess.run([\"toml\", \"get\", \"--toml-path\", \"test.toml\", \"tool.poetry.name\"], capture_output=True, text=True, check=True)\nprint(f\"Name: {result.stdout.strip()}\")\n\n# Set a value\nprint(\"\\nSetting tool.poetry.version to 0.2.0:\")\nsubprocess.run([\"toml\", \"set\", \"--toml-path\", \"test.toml\", \"tool.poetry.version\", \"0.2.0\"], check=True)\n\n# Verify the set value\nresult = subprocess.run([\"toml\", \"get\", \"--toml-path\", \"test.toml\", \"tool.poetry.version\"], capture_output=True, text=True, check=True)\nprint(f\"New Version: {result.stdout.strip()}\")\n\n# Add a section and a value (set command can add if key doesn't exist)\nprint(\"\\nAdding/Setting database.user:\")\nsubprocess.run([\"toml\", \"set\", \"--toml-path\", \"test.toml\", \"database.user\", \"admin\"], check=True)\n\n# Read the entire updated file\nprint(\"\\nUpdated TOML content:\")\nupdated_content = subprocess.run([\"cat\", \"test.toml\"], capture_output=True, text=True, check=True)\nprint(updated_content.stdout)\n\n# Clean up\nos.remove(\"test.toml\")","lang":"python","description":"This quickstart demonstrates how to use the `toml` command-line tool from Python scripts using `subprocess` to get and set values in a TOML file. It creates a temporary `test.toml` file, performs operations, and then cleans up."},"warnings":[{"fix":"Ensure the target key or path exists before attempting to set its value, or handle the non-zero exit code in scripts.","message":"In version 0.7.0, the `set` command was fixed to fail if the specified key was not found. Scripts that previously relied on `set` silently doing nothing or implicitly creating keys might experience failures.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Review and update scripts that interact with arrays of tables using `toml get` to align with the corrected behavior.","message":"Version 0.7.0 included a fix for the `get` command when dealing with arrays of tables. This correction means that scripts which previously worked around or relied on the buggy behavior might now produce different or unexpected results.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"When using in Python, call the `toml` command via `subprocess.run()` or similar methods.","message":"toml-cli is primarily a command-line interface tool and is not designed for direct programmatic import as a Python library (e.g., `import toml_cli`). Its functionality should be accessed by invoking the `toml` command via `subprocess` or directly in a shell environment.","severity":"gotcha","affected_versions":"all"},{"fix":"Update scripts to correctly interpret and handle the standardized exit codes and enhanced error messages provided by the `toml` command.","message":"Starting from version 0.7.0, the tool provides improved exit codes and more informative error messages. While beneficial, this might change the behavior of scripts that previously did not explicitly check exit codes or relied on specific (less verbose) error output.","severity":"gotcha","affected_versions":">=0.7.0"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}