The command line interface to Cacher.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Initial commit. Mar 24, 2018
src Check for updates. Oct 26, 2018
.editorconfig Initial commit. Mar 24, 2018
.eslintignore v1.0.0: Add run server (#7) Oct 25, 2018
.eslintrc Initial commit. Mar 24, 2018
.gitattributes Initial commit. Mar 24, 2018
.gitignore Initial commit. Mar 24, 2018
LICENSE v1.0.0: Add run server (#7) Oct 25, 2018
README.md Update `run-server`. Oct 26, 2018
package-lock.json 1.0.5 Nov 8, 2018
package.json 1.0.5 Nov 8, 2018
tsconfig.json Initial commit. Mar 24, 2018
tslint.json Initial commit. Mar 24, 2018

README.md

Cacher CLI

Cacher CLI - The command line interface to Cacher, the code snippet organizer for pro developers.

Cacher logo

Version Downloads/week License

The Cacher CLI allows power users to perform common actions on their Cacher libraries.

The CLI is constantly evolving. Check back often for updates and new commands.

Demo

CLI demo

Getting Started

Prerequisites

Instructions

To view your Cacher API credentials, visit: https://app.cacher.io/enter?action=view_api_creds

Note the API key and token in the Apps dialog footer:

Cacher logo

From a terminal window, run:

npm install -g @cacherapp/cli
cacher setup
? API key: ****************
? API token: ********************************

If all goes well, your credentials will be saved and you can execute CLI commands.

Commands

setup

Configure API credentials for Cacher CLI. To view your API token and key visit: https://app.cacher.test/enter?action=view_api_creds

USAGE
  $ cacher setup

OPTIONS
  -k, --key=key      api key for Cacher account
  -t, --token=token  token for Cacher account

EXAMPLES
  cacher setup
  ? API key: ****************
  ? API token: ********************************

  cacher setup --key=fe33cd82ae161ba1 --token=0134a0be884468829669c3be02c3a814

See code: lib/commands/setup/index.ts

snippets:add

Add a new snippet to your Cacher personal/team library. By default, creates snippet using clipboard contents. Append filename argument to use file contents instead.

USAGE
  $ cacher snippets:add [FILENAME]

OPTIONS
  -d, --description=description  snippet description
  -f, --filename=filename        filename for content (will override name of file passed in)
  -m, --team=team                screenname of team library that snippet will be created in
  -q, --quiet                    minimal feedback
  -t, --title=title              snippet title
  -u, --public                   save as public snippet

EXAMPLES
  $ cacher snippets:add
  ? Snippet title: Example from System Clipboard
  ? Description: Snippet created from contents in the clipboard.
  ? Filename: my_file_from_clipboard.md

  $ cacher snippets:add ~/MyCode/example.rb
  ? Snippet title: Example for CLI
  ? Description: This is an example for the Cacher CLI.

  $ cacher snippets:add --filename=my_file_from_clipboard.md \
      --title="Public example from System Clipboard" \
      --description="Snippet created from contents in the clipboard" \
      --team=cacher-dev-ops --public --quiet

See code: lib/commands/snippets/add.ts

run-server:start

Start a Run Server to accept requests from a given origin. The Run Server is used to run shell commands using Cacher snippet file contents. Run this command in tandom with the Cacher's standalone Run Server option.

For more information about the Run Server and its configuration, check out @cacherapp/cacher-run-server.

USAGE
  $ cacher run-server:start

OPTIONS
  -l, --logToFile      log output to server log file (~/.cacher/logs/run-server.log)
  -o, --origin=origin  http(s) origin for CORS requests (use "file://" with Cacher Desktop, "https://app.cacher.io" with Web App)
  -p, --port=port      port to run server on
  -t, --token=token    server token to check against while making connections
  -v, --verbose        show verbose logging

EXAMPLE
  $ cacher run-server:start -o https://myapp.dev -p 30012 -t my_server_token

    Listening on: http://localhost:30012
    Server token: my_server_token

Examples:

# With origin "https://app.cacher.io", generate port and token
cacher run-server:start

# With origin "file://" for Cacher Desktop Client, specify port and token
cacher run-server:start -o file:// -p 12345 -t secret

# Verbose output, logged to "~/.cacher/logs/run-server.log"
cacher run-server:start -v -l

Starting the server on a remote machine

Running a remote server ensures all your developers are able to run snippet file commands against the same environment.

Note: Since the commands will be run using the shell account from which you launch the CLI, we recommend you use only machines which are for testing or are ephemeral (i.e. Docker instances).

Example of launching with a secure tunnel (ngrok).

cacher run-server:start -p 39135 -t 4D5dzRGliafhGg~btNlR9 -o file:// -v
ngrok http 39135

You can then connect to the server via Cacher's Standalone option:

Connect to Standalone Run Server

run-server:config

Open the user configuration for the Run Server. Add rules here to handle additional file extensions.

USAGE
  $ cacher run-server:config

OPTIONS
  -e, --editor=editor  open configuration file with editor (i.e. "atom")

EXAMPLES
  $ cacher run-server:config
  $ cacher run-server:config -e atom

View documentation on the user configuration rule format.

run-server:log

Show the server log file.

USAGE
  $ cacher run-server:log

OPTIONS
  -n, --lines=lines  show the last n lines of the log
  -t, --tail         follow the Run Server log

EXAMPLE
  $ cacher run-server:log
  $ cacher run-server:log -t
  $ cacher run-server:log -n 100

Command Help

cacher help                 # View description and command topics
cacher help snippets        # Help on snippets commands
cacher help snippets:add    # Help and usage for the snippets:add command

Libraries Used

  • oclif - Heroku's open CLI framework.
  • chalk - Terminal styling for Node.
  • node-copy-paste - Cross-platform clipboard support.

Author / License

Released under the MIT License by Rui Jiang of Cacher.