The original `shyaml` Python library (v0.6.2) is a command-line tool designed for reading and querying YAML files. It enables shell scripts to easily access YAML data using simple dot-notation paths. While it remains available on PyPI, this Python version is in a low-maintenance state with no new features planned. Active development has transitioned to `shyaml-rs`, a Rust rewrite that offers significant performance improvements and additional features like write capabilities, while maintaining command-line interface compatibility.
pip install shyamlVerified import paths — ran on the pinned version, not inferred.
The primary use of `shyaml` is via the command line to extract values from YAML. It reads YAML from standard input and outputs the requested value to standard output. Paths are specified using dot notation.
Consider migrating to `shyaml-rs` for performance and new features. If you rely solely on CLI parsing, `shyaml-rs` should work seamlessly: `cargo install shyaml-rs` (if Rust is installed) or download a pre-built binary.
Always provide a default value as the third argument to `shyaml get-value` if the key might be missing and you don't want an error: `cat file.yaml | shyaml get-value some.path 'my_default_value'`
Ensure your scripts do not rely on a specific (or alphabetically sorted) order of keys if using older versions, or upgrade to 0.4.0+ if order preservation is critical. The current version (0.6.2) preserves order.
Use `shyaml --yaml get-value ...` or `shyaml -y get-value ...` to ensure strict YAML output for all values.
Ensure `shyaml` is installed by running `pip install shyaml`. Verify your system's PATH environment variable includes the directory where pip installs scripts (e.g., `~/.local/bin` on Linux or `Scripts` in your Python installation directory).
Double-check the filename and its full or relative path. Confirm that `config.yaml` exists and that `shyaml` has read permissions for the file and its parent directories.
Review `data.yaml` for any syntax issues. Use a YAML linter or validator to pinpoint and correct errors in the file's structure.
Install the package by running `pip install shyaml` in your terminal. If you are using multiple Python environments, ensure the correct one is activated.