• Stars
    star
    736
  • Rank 59,570 (Top 2 %)
  • Language
    JavaScript
  • Created over 8 years ago
  • Updated over 7 years ago

Reviews

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

Repository Details

curl on steroids

Vizsla

commandcar - curl on steroids

Join the chat at https://gitter.im/tikalk/commandcar

commandcar is a CLI tool that can easily communicate with any API. It simplifies unreadable and complicated curl commands, and has some nice features to make automation of API calls much simpler and bash scripts more streamlined.

Here's an example of what it can look like

commandcar facebook.like --post_id 123456789 --access_token abcdefghijklmnopqrstuvwxyz 

Installing

use npm to install commandcar.

sudo npm install commandcar -g

Using commandcar

A fresh commandcar install is a powerful yet empty skeleton. In order to make commandcar usable you need to install API definitions, and that's how you extend its power.

API Definitions are swagger2.0 files. You can create them yourself -- for example if you're developing an API and want to use commandcar to run automated tests against it -- or you can use existing public files. commandcar accepts either json or yaml swagger files.

Installing an API

There are three methods to install an API definition:

Installing a local file

commandcar install --name my_api --file ~/dev/commandcar/apis/my_api.json

Installing from a URL

commandcar install --name my_api --url http://some.domain.com/my/api/swagger.yaml

Installing from api-models

api-models is a GitHub repository of public available swagger files for many public APIs.

commandcar install --name instagram --api_model instagram.com/1.0.0

You can browse through the available APIs here and use the relative path to the directory containing the swagger file from this path onward. For example, the instagram API v1 resides here: https://github.com/APIs-guru/api-models/tree/master/APIs/instagram.com/1.0.0. Use "instagram.com/1.0.0" as the value for the --api_model argument. No trailing slashes please.

Upgrading/modifying an installed API

Simply run install again, it will overwrite the existing installation.

Uninstall

commandcar uninstall --name instagram

Invoking APIs using commandcar

Once you've installed API definitions, you can use commandcar -h to see the new commands and options you can use. Here's an example of the command output after installing the instagram API:

  Commands:

    instagram.get_geographies_media_recent [options] 
    instagram.get_locations_search [options]         
    instagram.get_locations [options]                
    instagram.get_locations_media_recent [options]   
    instagram.get_media_popular [options]            
    instagram.get_media_search [options]             
    instagram.get_media_shortcode [options]          
    instagram.get_media [options]                    
    instagram.get_media_comments [options]           
    instagram.post_media_comments [options]          
    instagram.delete_media_comments [options]        
    instagram.delete_media_likes [options]           
    instagram.get_media_likes [options]              
    instagram.post_media_likes [options]             
    instagram.get_tags_search [options]              
    instagram.get_tags [options]                     
    instagram.get_tags_media_recent [options]        
    instagram.get_users_search [options]             
    instagram.get_users_self_feed [options]          
    instagram.get_users_self_media_liked [options]   
    instagram.get_users_self_requested_by [options]  
    instagram.get_users [options]                    
    instagram.get_users_followed_by [options]        
    instagram.get_users_follows [options]            
    instagram.get_users_media_recent [options]       
    instagram.get_users_relationship [options]       
    instagram.post_users_relationship [options]      
    instagram.use [options]                          
    instagram.unuse                                  
    install [options]                                   
    uninstall [options]                                   

  Options:

    -h, --help  output usage information

You can then run help for any given command and see what your options are. For example, commandcar instagram.get_media_search -h will result in:

  Usage: instagram.get_media_search [options]

  Options:

    -h, --help                           output usage information
    -a, --access_token <access_token>    access_token
    -r, --ret [return value]             specify return value
    -l, --lat <lat>                      Latitude of the center search coordinate. If used, `lng` is required.
    -L, --lng <lng>                      Longitude of the center search coordinate. If used, `lat` is required.
    -m, --min_timestamp [min_timestamp]  A unix timestamp. All media returned will be taken later than this timestamp.
    -M, --max_timestamp [max_timestamp]  A unix timestamp. All media returned will be taken earlier than this timestamp.
    -d, --distance [distance]            Default is 1km (distance=1000), max distance is 5km.

use command

use is a special command that is added to any API that has securityDefinitions. If you're doing a lot of API calls with identical authorization parameters, for instance an Oauth2 access_token, then you can use them instead, and then they will be included in any following call to the API, until you unuse it or until you use another parameter value.

for example:

commandcar facebook.use --access_token abcdefghijklmnopqrstuvwxyz
commandcar facebook.like --post_id 1234567
commandcar facebook.comment --post_id 1234567 --text "what a cool post"
commandcar facebook.add_friend --uid 987654321

Note: Facebook is used as an example API throughout this doc, though we didn't practically implement it as a swagger file.

-r --ret

This is an option that is attached automatically to any command and enables you to specify exactly what you wish to receive as output.

So for example let's assume you make this call:

commandcar facebook.get_user --accees_token 123456 --ret first_name

Now let's assume that the API response is:

{
   "uid": "123456789",
   "first_name": "John",
   "last_name": "Doe"
}

Then the output would be simply John instead of the entire json.

Known issues

  • --ret can only work on json responses
  • command line functionality itself, i.e. required arguments are not enforced etc.
  • program can be heavy with lots of APIs installed. Needs to imporve caching for consecutive invokations

Gitter

We're on gitter if you want to talk with us.

More Repositories

1

redis-v8

Not Only SQL Database (NoSQL) redis with built in google V8 JS engine.
C++
13
star
2

tikal-advanced-pipeline

Advanced Jenkins Declarative Pipeline library
Groovy
10
star
3

resource-manager

Manage kubernetes resources (deletion, expiry, time-based scaling) for cost effective dev environments
Go
9
star
4

syncit

Open source project that make it easy to sync your calendars in real time.
TypeScript
8
star
5

youtube-remote-js

[fuse-day] a youtube application with a remote (on 2nd client) that controls it using fullstack javascript
JavaScript
8
star
6

ki-dashboard

Js Fullstack Dashboard Modularized app boilerplate - expressjs, angular, bootstrap, gulp.
HTML
6
star
7

TikalTimeTracker

JavaScript
5
star
8

nx-qwik

TypeScript
5
star
9

go-distribution-workshop

Go
4
star
10

fuse.dotnet.mongodb-blogengine

Access layer implementation (C#) based on MongoDB
C#
4
star
11

Flex-Foundation

A Flex framework which is a generic foundation for applicative infrastructures
ActionScript
4
star
12

Javascript-Roadmap

A full course with intro to javascript, jquery
JavaScript
3
star
13

amq-slow-consumers

handling slow or no consumers with activemq
Java
3
star
14

fuse.dbsynch.sample

sample application spring activemq
Java
3
star
15

maven-tomcat-deploy-sample

a sample deploying a few web apps to tomcat
Java
3
star
16

webcomponents-workshop

HTML
3
star
17

scaling-workshop-chef

Scaling workshop chef cookbooks
Ruby
3
star
18

backbone-workshop

Backbone.js based project for Tikal's workshop on Backbone.js
JavaScript
3
star
19

angular-best-practices

Applying best practices for angularjs & gulp
JavaScript
2
star
20

fuze-boilerplate

Tikal's Micro-Frontends Fuzeday Starter Kit
HTML
2
star
21

go-distribution-fuzeday

Go
2
star
22

reveal.js-tikal-theme

reveal.js theme for tikal
CSS
2
star
23

js-testing-workshop

learning to test with js: unit testing, automation and e2e
JavaScript
2
star
24

chef-server-install

Avoid all the clutter of Installing Chef Server
Shell
2
star
25

scaling-building-blocks

JavaScript
2
star
26

ex-gps-firehose

Java
2
star
27

tikal-alm-tools

Tikal ALM tools
Shell
2
star
28

fuse2020-use-package

Golang/Svelte web application for package recommendations. Fuse 2020, Team 1
Go
2
star
29

ex-device-manager

Java
2
star
30

releaseit

JavaScript
1
star
31

docker101

Repository for docker101 workshop
Shell
1
star
32

docker-youtube-remote

Repository for Docker 101 workshop
Shell
1
star
33

kube-finder

Go
1
star
34

eggroll

eggroll is a ui editor for creating and manipulating e2e tests that are written in cucumber flavour.
JavaScript
1
star
35

dev.hub.tikal.io

A kubernetes playground cluster using kops & terraform on AWS
Shell
1
star
36

Android4JavaWorkshopExamples

The example code presented in the Android for Java Developers workshop
1
star
37

tikal-hub

Tikal Hub is what is named, see more on
Java
1
star
38

LiveCast

Tikal's Fuseday JS Session Concept - a live screencast system for remote
CSS
1
star
39

tuningFork

tuningFork
JavaScript
1
star
40

ft-gps-tracker-ui

JavaScript
1
star
41

tikbot

Tikal's friendly bot
CoffeeScript
1
star
42

angular-cookbook

A storage for angular's related best practices, ready to use modules, directives, services, templates, tips & tricks
1
star
43

ttt-slack

JavaScript
1
star
44

hr-emplyee-profile-manager

JavaScript
1
star
45

perfectomobile

perfectomobile jenkins plugin
Java
1
star
46

.NetDec13FuseDay_MediaCenter

Media Center using .Net
JavaScript
1
star
47

riddle-master

online qte
1
star
48

tikal-ant-installer

Tikal Knowledge version to the legacy AntInstaller with respect to the creators of AntInstaller that no longer maintains the tool even that it has a very large install base
Java
1
star
49

dartagnan-infra

Infra repo for fuse dartagnan group
Smarty
1
star
50

Hibernate-Lazy-Chopper

Java
1
star
51

AngelSense-UI

JavaScript
1
star