Giter VIP home page Giter VIP logo

cables-cli's Introduction

cables-cli

Command line tool to export and download cables patches from the command line

             C   A   B   L   E   S   >>>  ___:_ _
       _ _:_______________ _____________ /   |\   _ _______
          |  _           /\\_           \    |\\.  _)     /\       ______         
    _____ | (/)        _/\\\(_______    /    |\\| /    __/\\\     /     /\    
   /   _/\_      _    /_\\\/_\\\\ _/   /     |\\|/     \_\\\/___ /     /\\\ 
  /   /_\\|_     |\     \\(    /\ \   /_    _:\\/__ /\_/       /_\   _/_\\/___
_/   /(     \    |_\     \__  /_\\_)    \         (_          /   \          /\
\           _\   \___     _/             \         /         /     \_       /\\\
 \_________(    _|\\\\     \_ ___________/   _    /_________/       /      /\\\/
  \\\\\\\\|_____)\\\        |\\\\\/         (/)  /\\\\\\\/                /_\\/
   \\\\\\\\\\\\\\\\\\_______:\\.\/______________/\\\\\\\\\_________________(\\ 
 _|.._     \\\\\\\)  \\\\\\\\\\| \\\\\\\\\\\\\\\\\\\/     \\\\\\\\\\\\\\\\\\\\
(_|||_)               \\\\\\\\\|  \\\\\\\\\\\\\\\\\/       \\\\\\\\\\\\\\\\\\( 
 ---|-->> 

Installation

Run npm install -g @cables/cables.
Create an API key on cables.gl/settings —> navigate to API key —> press Generate. When you first start the tool it will show a prompt for the API key. Once entered your API key will be stored in ~/.cablesrc.

Run

Export

To export and download a cables patch into a specific directory run:

cables --export [CABLES PATCH ID] -d [DESTINATION]

You can find the patch ID by opening your patch in the cables editor – the last part of the URL is the patch ID, e.g.:

https://cables.gl/edit/rTVxvC
—> rTVxvC is the patch ID

Example:

cables --export rTVxvC -d 'my-patch'

Please note: Running the command will overwrite everything in the my-patch-folder.

Arguments

  • -e / --export [PATCH ID]: Export patch
  • -C / --code [PATCH ID],[PATCH ID],[PATCH ID]: Export ops code for patch(es)
  • -d / --destination [DESTINATION]: Folder to download the patch to, can either be absolute or relative
  • -i / --no-index : Removes the index.html file when set
  • -x / --no-extract : do not extract the downloaded zip file
  • -j / --json-filename [JSON FILENAME] : Define the filename of the patch json file
  • -c / --combine-js : combine javascript and json into a single patch.js
  • -a / --assets <auto|all|none>: export assets of patch, defaults to "auto"
  • -b / --skip-backups: do not include backup files in patch export
  • -f / --no-subdirs: put js and assets into same directory as index.html ("flat export")
  • -D / --dev: export from dev server

Use as a module

Install as dependency:

npm install --save @cables/cables

Export:

cables.export(options, onFinished, onError);

Simple Export Example:

var cables = require('@cables/cables');

cables.export({
  patchId: 'rTVxvC',
  destination: 'patch' 
}, onFinished, onError);

function onFinished() {
  console.log('Export finished!');
}

function onError(err) {
  console.log('There was an error exporting your patch :/');
}

Advanced Export Example:

var cables = require('@cables/cables');

cables.export({
  patchId: 'rTVxvC',
  destination: 'patch',
  noIndex: true,
  jsonFilename: 'my-patch' /* patch will be stored as my-patch.json */
}, onFinished, onError);

function onFinished(filename) {
  console.log('Export finished: '+filename);
}

function onError(err) {
  console.log('There was an error exporting your patch :/');
}

Export Code (-C) Example:

If you just need the op-code of one or more patches you created, you can use the -C option and provide a comma-seperated list of patch-ids to download ops.js with all code included.

This is helpful, when you want to add multiple patches to one page. Download the patches individually (do NOT use --combine-js), load libs and cables.min.js as provided in the individual index.html and swap out ops.js with this download.

cables -C -d 'public' rTVxvC
var cables = require('@cables/cables');

cables.code({
  code: 'one,two,thee',
  destination: 'patch' 
}, onFinished, onError);

function onFinished() {
  console.log('Export finished!');
}

function onError(err) {
  console.log('There was an error exporting your patch :/');
}

Use in package.json:

{
  "scripts": {
      "patchup": "cables -c -i -d 'public' -e rTVxvC",
      "code": "cables -C -d 'public' rTVxvC"
  }
}

The project contains an example-package.json with patchup and deploy as predefined scripts.

Further Infos

For more infos on the cables API see cables API docs.

cables-cli's People

Contributors

steam0r avatar pandrr avatar anticore avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.