• Stars
    star
    112
  • Rank 301,964 (Top 7 %)
  • Language
    Crystal
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command line HTTP client written in Crystal

Crul Build Status

Crul is a curl replacement, that is, it's a command line HTTP client. It has fewer features and options, but it aims to be more user friendly. It's heavily inspired by httpie.

It's written in the Crystal language. It's in an early stage but it allows already basic usage.

Features

  • Fast
  • No dependencies, easy to install
  • Basic HTTP features (method, request body, headers)
  • Syntax highlighting of the output (JSON and XML)
  • Basic authentication
  • Cookie store
  • Bash completion of commands and options

Planned features

  • User friendly headers and request body generation (similar to httpie's)
  • Digest authentication
  • More fancy stuff

Installation

Mac

brew tap porras/crul
brew install crul

Or, if you want to install the latest, unreleased version:

brew tap porras/tap
brew install crul --HEAD

Linux

Ubuntu/Debian

There is an APT repository with signed packages of the latest crul version. To setup this repo and install crul, run the following commands (as root or with sudo):

apt-key adv --keyserver keys.gnupg.net --recv-keys ED2715FE
echo "deb http://iamserg.io/deb packages main" > /etc/apt/sources.list.d/iamserg.io.list
apt-get update
apt-get install crul

Other distributions

See how to install from source below.

From source

If there are no binary packages for your OS version, you can install crul downloading the zip or tarball and building it from source. See Development for instructions.

Completion

After installation, add this line to your .bashrc (only Bash supported at this moment):

eval "$(crul --completion)"

You don't need this if you installed via Homebrew (it's automatic).

Usage

Usage: crul [method] URL [options]

HTTP methods (default: GET):
    get, GET                         Use GET
    post, POST                       Use POST
    put, PUT                         Use PUT
    delete, DELETE                   Use DELETE

HTTP options:
    -d DATA, --data DATA             Request body
    -d @file, --data @file           Request body (read from file)
    -H HEADER, --header HEADER       Set header
    -a USER:PASS, --auth USER:PASS   Basic auth
    -c FILE, --cookies FILE          Use FILE as cookie store (reads and writes)

Response formats (default: autodetect):
    -j, --json                       Format response as JSON
    -x, --xml                        Format response as XML
    -p, --plain                      Format response as plain text

Other options:
    -h, --help                       Show this help
    -V, --version                    Display version

Examples

GET request

$ crul http://httpbin.org/get?a=b
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 11 Mar 2015 07:57:33 GMT
Content-type: application/json
Content-length: 179
Connection: keep-alive
Access-control-allow-origin: *
Access-control-allow-credentials: true

{
  "args": {
    "a": "b"
  },
  "headers": {
    "Content-Length": "0",
    "Host": "httpbin.org"
  },
  "origin": "188.103.25.204",
  "url": "http://httpbin.org/get?a=b"
}

PUT request

$ crul put http://httpbin.org/put -d '{"a":"b"}' -H Content-Type:application/json
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 11 Mar 2015 07:58:54 GMT
Content-type: application/json
Content-length: 290
Connection: keep-alive
Access-control-allow-origin: *
Access-control-allow-credentials: true

{
  "args": {},
  "data": "{\"a\":\"b\"}",
  "files": {},
  "form": {},
  "headers": {
    "Content-Length": "9",
    "Content-Type": "application/json",
    "Host": "httpbin.org"
  },
  "json": {
    "a": "b"
  },
  "origin": "188.103.25.204",
  "url": "http://httpbin.org/put"
}

Development

You'll need Crystal 0.33 installed (it might work with older or newer versions, but that's the one that's tested).

After checking out the repo (or decompressing the tarball with the source code), run shards to get the development dependencies, and make to run the tests and compile the source. Optionally, you can run make install to install it (as a default, in /usr/local/bin, override it running PREFIX=/opt/whatever make install).

Contributing

  1. Fork it ( https://github.com/porras/crul/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

You can also contribute by trying it and reporting any issue you find.

Copyright

Copyright (c) 2015-2016 Sergio Gil. See LICENSE for details.

More Repositories

1

i3-keyboard-layout

Change keyboard layout with a keystroke + show it in the status bar
Shell
93
star
2

dmenu-emoji

Search an emoji by name and copy it to the clipboard [i3, dmenu, rofi]
Shell
63
star
3

mrproper

Property Based Testing in Ruby
Ruby
34
star
4

imdb

Wrapper library to search IMDB parsing its HTML
Ruby
29
star
5

duct

Duct allows you to embed a Gemfile in a single file script
Ruby
27
star
6

livevalidation

Client-side validations for Ruby on Rails (using javascript library livevalidation.com)
Ruby
26
star
7

tlcr

Simple terminal-based client for TLDR pages, written in Crystal. TLDR pages is a collection of simplified and community-driven man pages.
Crystal
23
star
8

session

Cookie based sessions in Crystal HTTP applications
Crystal
23
star
9

rakegrowl

Get Growled when your long running rake tasks finish
Ruby
19
star
10

ghcontributors

Github Contributors
JavaScript
13
star
11

mock

Doubles (stubs and mocks) library for Crystal, inspired by the API of rspec-mocks
Crystal
13
star
12

evil-ruby-text-objects

Emacs package that adds some text objects and keybindings to work with Ruby code with Evil.
Emacs Lisp
10
star
13

rosendo

Minimalistic and naive Sinatra reimplementation, without any dependencies other than the ruby socket library
Ruby
9
star
14

language_detection

Rails plugin to detect the language of a given string
Ruby
8
star
15

sonic-pi-akai-apc-mini

Utility functions to use the Akai APC mini MIDI controller with Sonic Pi
Ruby
6
star
16

includer

Easy way to include files into another files
Ruby
6
star
17

store

File based storage library for Crystal (inspired by Ruby's PStore)
Crystal
6
star
18

random_items

Rails plugin to pick random items from a model (without using :order => "RAND()")
Ruby
6
star
19

rubystdlib

Slides, examples and reference links from my talk “5 gems of the Ruby Standard Library”
Ruby
5
star
20

madrid-rb-feb-2010

Sample application I used in my talk about acceptance testing with Steak and Capybara in Madrid-rb
Ruby
5
star
21

RGSoC_material

Ruby
5
star
22

tkn2

Tkn2 is a presentation tool for the terminal heavily inspired by Xavier Noria's tkn (Terminal Keynote)
Ruby
5
star
23

pipes

Ruby
4
star
24

nested_open_struct

Ruby
4
star
25

enumerator-talk

Examples for the talk about Enumerable and Enumerator I gave in RUG::B July 2015
3
star
26

-

Semantically awesome testing library
Ruby
3
star
27

twitter_common_friends

GreaseMonkey script which shows your common friends with any other Twitter user (a la Facebook)
JavaScript
3
star
28

hyperdelegate

Rails plugin which adds two options to delegate to make it more flexible and support two frequent patterns in delegation.
3
star
29

trenza

Ruby
2
star
30

pouchdb_test

JavaScript
2
star
31

ujfalusi

Ruby
2
star
32

lightning.io

Ruby
1
star
33

despotify-ruby

C
1
star
34

sem_ver

Semantic Versioning parser
Ruby
1
star
35

magit-spinner

Emacs Lisp
1
star
36

fragments

1
star
37

sonic-pi-mode

Emacs Lisp
1
star