toml2json-1.3.2/.cargo_vcs_info.json0000644000000001360000000000100127660ustar { "git": { "sha1": "bf914425811ad1b410d1eafbd8d6f9c6a39545d2" }, "path_in_vcs": "" }toml2json-1.3.2/.github/dependabot.yml000064400000000000000000000003061046102023000157450ustar 00000000000000version: 2 updates: - package-ecosystem: cargo directory: "/" schedule: interval: weekly - package-ecosystem: github-actions directory: / schedule: interval: weekly toml2json-1.3.2/.github/workflows/ci.yml000064400000000000000000000013621046102023000162730ustar 00000000000000name: CI on: push: branches: - main pull_request: permissions: {} jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Format run: cargo fmt && git diff --exit-code - name: Lint run: | rustup update rustup component add clippy cargo clippy -- -D warnings build-stable: runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Toolchain run: rustup update - name: Build run: cargo build toml2json-1.3.2/.github/workflows/release-crate.yml000064400000000000000000000012531046102023000204130ustar 00000000000000on: release: types: - published name: release to crates.io permissions: {} jobs: crates: runs-on: ubuntu-latest permissions: id-token: write # for trusted publishing environment: name: crates.io url: https://crates.io/crates/toml2json steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - uses: rust-lang/crates-io-auth-action@e919bc7605cde86df457cf5b93c5e103838bd879 # v1.0.1 id: auth - name: publish to crates.io run: cargo publish env: CARGO_REGISTRY_TOKEN: "${{ steps.auth.outputs.token }}" toml2json-1.3.2/.github/workflows/release-pypi.yml000064400000000000000000000130601046102023000202750ustar 00000000000000name: toml2json wheel builds for PyPI 🐍 on: push: branches: - main release: types: - published workflow_dispatch: permissions: contents: read jobs: linux: name: Build Linux wheels (manylinux) runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: ubuntu-24.04 target: x86_64 manylinux: "2_28" # - runner: ubuntu-24.04 # target: x86 # manylinux: "auto" - runner: ubuntu-24.04 target: aarch64 manylinux: "2_24" - runner: ubuntu-24.04 target: armv7 manylinux: "2_28" # - runner: ubuntu-24.04 # target: s390x # manylinux: "2_28" # - runner: ubuntu-24.04 # target: ppc64le # manylinux: "2_28" steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Build wheels uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4 with: target: ${{ matrix.platform.target }} args: --release --out dist manylinux: ${{ matrix.platform.manylinux }} - name: Upload wheels uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: wheels-linux-${{ matrix.platform.target }} path: dist musllinux: name: Build Linux wheels (musllinux) runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: ubuntu-24.04 target: x86_64 # - runner: ubuntu-24.04 # target: x86 - runner: ubuntu-24.04 target: aarch64 - runner: ubuntu-24.04 target: armv7 steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Build wheels uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4 with: target: ${{ matrix.platform.target }} args: --release --out dist manylinux: musllinux_1_2 - name: Upload wheels uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: wheels-musllinux-${{ matrix.platform.target }} path: dist windows: name: Build Windows wheels runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: windows-latest target: x64 - runner: windows-latest target: x86 steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Build wheels uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4 with: target: ${{ matrix.platform.target }} args: --release --out dist - name: Upload wheels uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: wheels-windows-${{ matrix.platform.target }} path: dist macos: name: Build macOS wheels runs-on: ${{ matrix.platform.runner }} strategy: matrix: platform: - runner: macos-15 target: x86_64 - runner: macos-15 target: aarch64 steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Build wheels uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4 with: target: ${{ matrix.platform.target }} args: --release --out dist - name: Upload wheels uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: wheels-macos-${{ matrix.platform.target }} path: dist sdist: name: Build source distribution runs-on: ubuntu-latest steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Build sdist uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4 with: command: sdist args: --out dist - name: Upload sdist uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: wheels-sdist path: dist release: name: Release runs-on: ubuntu-latest environment: name: pypi url: https://pypi.org/p/toml2json/ if: ${{ github.event_name == 'release' }} needs: [linux, musllinux, windows, macos, sdist] permissions: # Use to sign the release artifacts id-token: write # Used to upload release artifacts contents: write # Used to generate artifact attestation attestations: write steps: - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 - name: Generate artifact attestation uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0 with: subject-path: "wheels-*/*" - name: Publish to PyPI if: ${{ github.event_name == 'release' }} uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4 with: command: upload args: --non-interactive --skip-existing wheels-*/* toml2json-1.3.2/.github/workflows/zizmor.yml000064400000000000000000000010571046102023000172330ustar 00000000000000name: GitHub Actions Security Analysis with zizmor 🌈 on: push: branches: ["main"] pull_request: branches: ["**"] permissions: {} jobs: zizmor: name: Run zizmor 🌈 runs-on: ubuntu-latest permissions: security-events: write steps: - name: Checkout repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - name: Run zizmor 🌈 uses: zizmorcore/zizmor-action@5ca5fc7a4779c5263a3ffa0e1f693009994446d1 # v0.1.2 toml2json-1.3.2/.gitignore000064400000000000000000000000101046102023000135350ustar 00000000000000/target toml2json-1.3.2/Cargo.lock0000644000000260700000000000100107460ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "anstream" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", "utf8parse", ] [[package]] name = "anstyle" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ "windows-sys 0.48.0", ] [[package]] name = "anstyle-wincon" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", "windows-sys 0.52.0", ] [[package]] name = "anyhow" version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "clap" version = "4.5.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" version = "4.5.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", ] [[package]] name = "clap_lex" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "equivalent" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" [[package]] name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "indexmap" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "itoa" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "proc-macro2" version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "serde" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" dependencies = [ "itoa", "memchr", "ryu", "serde", ] [[package]] name = "serde_spanned" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83" dependencies = [ "serde", ] [[package]] name = "strsim" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "syn" version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "toml" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75129e1dc5000bfbaa9fee9d1b21f974f9fbad9daec557a521ee6e080825f6e8" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "toml_parser", "toml_writer", "winnow", ] [[package]] name = "toml2json" version = "1.3.2" dependencies = [ "anyhow", "clap", "serde", "serde_json", "toml", ] [[package]] name = "toml_datetime" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3" dependencies = [ "serde", ] [[package]] name = "toml_parser" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" dependencies = [ "winnow", ] [[package]] name = "toml_writer" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" [[package]] name = "unicode-ident" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets 0.48.0", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.0", ] [[package]] name = "windows-targets" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", "windows_i686_gnu 0.48.0", "windows_i686_msvc 0.48.0", "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm 0.48.0", "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows-targets" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ "windows_aarch64_gnullvm 0.52.0", "windows_aarch64_msvc 0.52.0", "windows_i686_gnu 0.52.0", "windows_i686_msvc 0.52.0", "windows_x86_64_gnu 0.52.0", "windows_x86_64_gnullvm 0.52.0", "windows_x86_64_msvc 0.52.0", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_aarch64_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_i686_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnu" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "windows_x86_64_msvc" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" toml2json-1.3.2/Cargo.toml0000644000000023430000000000100107660ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "toml2json" version = "1.3.2" authors = ["William Woodruff "] build = false autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "Convert TOML to JSON" homepage = "https://github.com/woodruffw/toml2json" readme = "README.md" keywords = [ "cli", "toml", "json", ] categories = [ "command-line-utilities", "development-tools", "encoding", ] license = "MIT" [[bin]] name = "toml2json" path = "src/main.rs" [dependencies.anyhow] version = "1.0" [dependencies.clap] version = "4.5" [dependencies.serde] version = "1.0" features = ["derive"] [dependencies.serde_json] version = "1.0" [dependencies.toml] version = "0.9" [profile.release] lto = true toml2json-1.3.2/Cargo.toml.orig000064400000000000000000000007761046102023000144570ustar 00000000000000[package] name = "toml2json" description = "Convert TOML to JSON" license = "MIT" version = "1.3.2" authors = ["William Woodruff "] edition = "2021" homepage = "https://github.com/woodruffw/toml2json" readme = "README.md" keywords = ["cli", "toml", "json"] categories = ["command-line-utilities", "development-tools", "encoding"] [dependencies] anyhow = "1.0" clap = "4.5" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" toml = "0.9" [profile.release] lto = true toml2json-1.3.2/LICENSE000064400000000000000000000021251046102023000125630ustar 00000000000000The MIT License (MIT) Copyright (c) 2021 William Woodruff Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. toml2json-1.3.2/README.md000064400000000000000000000055711046102023000130450ustar 00000000000000toml2json ========= [![CI](https://github.com/woodruffw/toml2json/actions/workflows/ci.yml/badge.svg)](https://github.com/woodruffw/toml2json/actions/workflows/ci.yml) [![Crates.io](https://img.shields.io/crates/v/toml2json)](https://crates.io/crates/toml2json) ![PyPI - Version](https://img.shields.io/pypi/v/toml2json) A command-line tool that converts TOML to JSON. Nothing more, nothing less. ## Installation ### Cargo ```bash cargo install toml2json ``` ### PyPI **NOTE**: [toml2json on PyPI](https://pypi.org/project/toml2json/) was originally a pure Python CLI; ownership of the name on PyPI was transferred to [woodruffw](https://pypi.org/user/woodruffw/) for this Rust-based CLI in August 2025. Versions prior to 0.1.0 on PyPI are the old pure Python version. ```bash uvx toml2json uv tool install toml2json pipx install toml2json # or pip install, if you're in a virtual environment ``` ### Homebrew `toml2json` is available via [Homebrew](https://brew.sh): ```bash brew install toml2json ``` ### Alpine Linux `toml2json` is available for [Alpine Edge](https://pkgs.alpinelinux.org/packages?name=toml2json&branch=edge). It can be installed via [apk](https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper) after enabling the [testing repository](https://wiki.alpinelinux.org/wiki/Repositories). ```bash apk add toml2json ``` ### Arch Linux If you're using Arch Linux, you can install `toml2json` using an [AUR helper](https://wiki.archlinux.org/title/AUR_helpers). For example: ```bash paru -S toml2json ``` ### Nixpkgs ``` nix-env --install toml2json ``` Please let us know if you package `toml2json` for another package manager or ecosystem! ## Usage Convert TOML on `stdin` to JSON, filtering it through `jq`: ```bash $ toml2json <<< 'wow = "amazing"' | jq ``` Produces: ```json { "wow": "amazing" } ``` Convert TOML from a file and pretty-print it without `jq`: ```bash $ toml2json --pretty ~/.config/kbs2/kbs2.conf ``` Produces: ```json { "age-backend": "RageLib", "error-hook": "~/.config/kbs2/hooks/error-hook-notify", "keyfile": "REDACTED-GO-AWAY", "public-key": "REDACTED-GO-AWAY", "reentrant-hooks": false, "store": "~/.kbs2-store", "wrapped": true, "generators": [ { "alphabet": "abcdefghijklmnopqrstuvwxyz0123456789(){}[]-_+=", "length": 16, "name": "default" } ], "commands": { "edit": { "editor": "subl -w", "post-hook": "~/.config/kbs2/hooks/push-repo" }, "new": { "generate-on-empty": true, "post-hook": "~/.config/kbs2/hooks/push-repo" }, "pass": { "clear-after": true, "clear-hook": "~/.config/kbs2/hooks/pass-clear-notify", "clipboard-duration": 10, "x11-clipboard": "Clipboard" }, "rm": { "post-hook": "~/.config/kbs2/hooks/push-repo" } } } ``` Amazing. What more could you want? Hopefully nothing, because it will never do anything else. toml2json-1.3.2/pyproject.toml000064400000000000000000000005201046102023000144670ustar 00000000000000[build-system] requires = ["maturin>=1.0,<2.0"] build-backend = "maturin" # NOTE: This section is a stub; needed to prevent # `uv run --only-group docs` from failing. [project] name = "toml2json" dynamic = ["version", "readme"] # Arbitrarily set to the oldest non-EOL Python. requires-python = ">=3.9" [tool.maturin] bindings = "bin" toml2json-1.3.2/src/main.rs000064400000000000000000000041571046102023000136460ustar 00000000000000#![forbid(unsafe_code)] use std::fs; use std::io::{self, Read}; use anyhow::{Context, Result}; use clap::{Arg, ArgAction, Command}; fn app() -> Command { Command::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) .about(env!("CARGO_PKG_DESCRIPTION")) .arg( Arg::new("pretty") .help("pretty print the JSON") .short('p') .long("pretty") .action(ArgAction::SetTrue), ) .arg( Arg::new("input") .help("the TOML to convert") .index(1) .default_value("-"), ) } fn main() -> Result<()> { let matches = app().get_matches(); // Get our input source (which can be - or a filename) and its // corresponding buffer. We don't bother streaming or chunking, // since the `toml` crate only supports slices and strings. let input_src = matches.get_one::("input").unwrap(); let input_buf = match input_src.as_ref() { "-" => { let mut input_buf = String::new(); io::stdin() .read_to_string(&mut input_buf) .with_context(|| "failed to collect stdin")?; input_buf } input => fs::read_to_string(input) .with_context(|| format!("failed to collect from input: {input}"))?, }; // Turn our collected input into a value. We can't be more specific than // value, since we're doing arbitrary valid TOML conversions. let value = toml::from_str::(&input_buf) .with_context(|| format!("parsing TOML from {input_src} failed"))?; // Spit back out, but as JSON. `serde_json` *does* support streaming, so // we do it. if *matches.get_one::("pretty").unwrap() { serde_json::to_writer_pretty(io::stdout(), &value) } else { serde_json::to_writer(io::stdout(), &value) } .with_context(|| "JSON serialization and/or stdout streaming failed")?; Ok(()) } #[cfg(test)] mod tests { use super::*; #[test] fn test_app() { app().debug_assert(); } }