All Projects → lucasepe → uri

lucasepe / uri

Licence: BSD-3-Clause license
A commandline tool to resolve URI Templates expressions as specified in RFC 6570.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to uri

uri
A type to represent, query, and manipulate a Uniform Resource Identifier.
Stars: ✭ 16 (-5.88%)
Mutual labels:  uri-templates
maven-artifacts-uploader
command line tool for uploading directory of maven artifacts to nexus 3.x repository
Stars: ✭ 30 (+76.47%)
Mutual labels:  commandline-tool
py3createtorrent
Create torrents via command line!
Stars: ✭ 16 (-5.88%)
Mutual labels:  commandline-tool
cook
macOS command line tool to automate common iOS development tasks
Stars: ✭ 50 (+194.12%)
Mutual labels:  commandline-tool

URI

Are you tired to build, concat, replace URL(s) (via shell scripts sed/awk/tr) from your awesome commandline pipeline?

Well! here is the missing piece: uri!

         _            _  
o  / / _|     URI      |_ 
o / /   |_ Templates  _|

A commandline tool to resolve URI Templates expressions as specified in RFC 6570.

For a complete syntax reference check the RFC6570 specs here: https://tools.ietf.org/html/rfc6570#section-2.

Expressions are placeholders which are to be substituted by the values their variables reference.

http://example.org/~{username}/
http://example.org/dictionary/{term:1}/{term}
http://example.org/search{?q*,lang}

How to use uri

This tool takes a JSON as input data model containing the values ​​of the variables. Example:

{
    "username": "scarlett",
    "term": "black widow",
    "q": {
        "a": "mars",
        "b": "jupiter"
    },
    "lang": "en"
}

You can pass this JSON as file using the -i flag:

$ uri -i data.json http://example.org/~{username}/{term:1}/{term}{?q*,lang}
http://example.org/~scarlett/b/black%20widow?q*

Or you can pipe it directly to the tool (and this the most interesting use case):

$ cat data.json | uri http://example.org/~{username}/{term:1}/{term}{?q*,lang}
http://example.org/~scarlett/b/black%20widow?q*

Using commandline pipes you can achieve tasks like this:

$ cat testdata/pets.json \
  | jq --raw-output '.pets[1] | {category: .species, year: .birthYear}' \
  | uri https://pets.api.com/{category}{?year} \
  | xargs curl

Installation Steps

In order to use the crumbs command, compile it using the following command:

go get -u github.com/lucasepe/uri

This will create the executable under your $GOPATH/bin directory.

Ready-To-Use Releases

If you don't want to compile the source code yourself, here you can find the executables for:

  • MacOS
  • Linux (amd64, arm7, arm64)
  • Windows

Credits

uri was possible thanks to the Joshua Tacoma URI Template library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].