#toml #command-line #cli #information #obtaining #package-version #tq

bin+lib tomlq

A tool for obtaining information from a TOML file on the command line

6 releases

new 0.1.6 Jul 9, 2024
0.1.5 Jul 1, 2024
0.1.0 Aug 26, 2017

#1 in #obtaining

Download history 112/week @ 2024-03-17 136/week @ 2024-03-24 172/week @ 2024-03-31 128/week @ 2024-04-07 220/week @ 2024-04-14 159/week @ 2024-04-21 205/week @ 2024-04-28 335/week @ 2024-05-05 184/week @ 2024-05-12 150/week @ 2024-05-19 175/week @ 2024-05-26 332/week @ 2024-06-02 400/week @ 2024-06-09 200/week @ 2024-06-16 193/week @ 2024-06-23 494/week @ 2024-06-30

1,297 downloads per month

MIT license

13KB
169 lines

tq

This repository was previously available under cryptaliagy/tq-rs, and by the crate tq-rs.

The current iteration of this crate supports both the tq and tomlq binaries. Wherever possible, tq should be preferred, and tomlq will be removed from the crate for the 0.2.0 version (scheduled for January 1, 2025).

Installing

  • Using cargo (compiles from source): cargo install tomlq
  • Using cargo-binstall (downloads from Github Releases page): cargo binstall -y tomlq

Migrating from tq-rs crate

The only step that is required to migrate from tq-rs to tomlq is to change the cargo install (or cargo binstall) step from referencing tq-rs to referencing tomlq. The binary has the same name, and the usage is the same.

Usage

N.B. Use tq --help after installing for more information

Getting package version from Cargo.toml

tq -f Cargo.toml 'package.version'

Exporting package version as job output in Github Actions

jobs:
  get-version:
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.get-version.outputs.version }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install cargo-binstall
        run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash

      - name: Install tq
        run: cargo binstall -y tomlq

      - id: get-version
        name: Output the current version of the project
        run: echo "version=$(tq -f Cargo.toml 'package.version')" >> "$GITHUB_OUTPUT"

N.B. See the release pipeline file for how this job is used.

Contributions

Contributions are welcome! I just needed this one feature, so I haven't spent any additional time on this. If you have an idea, please feel free to open an issue, if you've implemented some additional features, please feel free to open a PR!

License

Licensed under the MIT License

Dependencies

~1–12MB
~100K SLoC