Skip to main content

Codehooks CLI tool

Command line interface (CLI) for codehooks.io. (NPM)

Version: 1.0.27

The CLI lets you manage projects and spaces/instances (serverless functions + datastore + settings) from the command line.

  • Create a new Project: coho create myproject
  • Initialise existing Project on disk: coho init
  • Show project information, API keys etc.: coho info
  • Create a new Space: coho add myspace
  • Create a new Collection: coho createcoll 'customers'
  • Invite a developer to the project: coho invite [email protected] myproject
  • Deploy your app to the serverless cloud: coho deploy
  • See what's going on with real time logs: coho logs -f
  • Query a Space / datastore: coho query --collection products --query 'type=soft'

Install

$ npm i codehooks -g

Usage

$ codehooks --help

Help output:

codehooks <command>

Commands:
codehooks admin Open the codehooks.io admin account UI at account.codehooks.io
codehooks docs Open the codehooks.io documentation
codehooks login [provider] Authenticate CLI - sign up and/or sign in
codehooks logout Log out of the CLI
codehooks account Show info about account, projects and invitations
codehooks invite [email] [projectname] Invite user to project
codehooks join [projectname] Join project
codehooks leave [projectname] Leave project
codehooks create [projectname] [teamid] [description] Create and initialize a new codehooks project [aliases: init]
codehooks init [projectname] [space] Initialise an existing project space in the current folder. Sets up default CRUD template in index.js.
codehooks add [space] [projectname] [restricted] Add new space to project
codehooks use [name] Set active space
codehooks info [projectname] [space] Show info about project and spaces
codehooks stats [project] Show usage metrics for project spaces
codehooks verify [dir] Compile code (defaults to current dir) [aliases: compile, ver, comp]
codehooks deploy Deploys current codehook folder [aliases: de, dep]
codehooks undeploy Undeploy current codehook folder [aliases: unde, undep]
codehooks log [space] [tail] [follow] [context] Show system logs for a space. [aliases: logs]
codehooks count [collection] [space] Count objects in a collection in current space [aliases: co]
codehooks query [collection] [query] [space] Run query on collection in current space [aliases: q]
codehooks createindex [collection] [index] [space] Add field(s) to a query index [aliases: index, idx, create-index]
codehooks dropindex [collection] [index] [space] Remove field(s) from a query index [aliases: removeindex, remove-index, rmindex, delete-index]
codehooks get [key] [keyspace] [space] [json] Retrieve key-value pair(s) from a space
codehooks set [key] [val] Set key-value pair in a space
codehooks del [key] [keyspace] [space] [json] Delete key-value pair in a space
codehooks collection [project] [output] Show collections for space [aliases: coll, col, ls]
codehooks createcollection [collection] Create a new collection [aliases: createcoll, add-collection]
codehooks dropcollection [collection] Delete all data in collection and remove collection name [aliases: dropcoll, rmcoll, deletecoll]
codehooks add-schema [collection] [schema] Add a JSON schema to a collection [aliases: schema, create-schema]
codehooks remove-schema [collection] Remove JSON schema for a collection [aliases: delete-schema, del-schema]
codehooks cap-collection [collection] [cap] [capdelay] Cap a collection [aliases: cap, cap-coll, capcoll]
codehooks uncap-collection [collection] Remove cap on a collection [aliases: uncap]
codehooks import [filepath] [collection] [project] [space] [dryrun] Import JSON or CSV data from file [aliases: imp]
codehooks export [collection] [project] [space] Export JSON or CSV data
codehooks add-token [readonly] Add token to space
codehooks remove-token [token] Remove token from space
codehooks set-env [key] [value] [encrypted] Set environment variable for space
codehooks remove-env [key] Remove environment variable from space
codehooks jwks [url] Set/replace JWKS endpoint for OAuth2 authentication. Set to "" (empty string) to remove.
codehooks whitelist [ip] Add host to whitelist (use to restrict space access)
codehooks whitelist-remove [ip] Remove host from whitelist
codehooks completion Generate command completion script. Just add this to your .bashrc, .bash_profile, .zshrc (or similar) on *nix machines
codehooks remove-project [projectname] Remove the project
codehooks remove-space [space] [projectname] Remove space and data
codehooks admintokens Show active admintokens for account or team
codehooks add-admintoken Add admin token to account or team (for use with CI)
codehooks remove-admintoken Remove admin token from account or team
codehooks localserver [port] Run a local development server. Provides a local (JSON) database for test purpouses [aliases: serve, run, demo]

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]


No project active in this folder! Use 'coho create' or 'codehooks create' to create a new project.

created by Codehooks AS - [email protected]

Available commands

admin

$ codehooks admin --help

Help output:

codehooks admin

Open the codehooks.io admin account UI at account.codehooks.io

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

docs

$ codehooks docs --help

Help output:

codehooks docs

Open the codehooks.io documentation

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

login

$ codehooks login --help

Help output:

codehooks login [provider]

Authenticate CLI - sign up and/or sign in

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

logout

$ codehooks logout --help

Help output:

codehooks logout

Log out of the CLI

Options:
-d, --debug show debug (verbose) information
--dir [default: "."]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

account

$ codehooks account --help

Help output:

codehooks account

Show info about account, projects and invitations

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

invite

$ codehooks invite --help

Help output:

codehooks invite [email] [projectname]

Invite user to project

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
-t, --email [string] [required]
--role [string] [default: "ADMIN"]
--remove remove invitation [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

join

$ codehooks join --help

Help output:

codehooks join [projectname]

Join project

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

leave

$ codehooks leave --help

Help output:

codehooks leave [projectname]

Leave project

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

create

$ codehooks create --help

Help output:

codehooks create [projectname] [teamid] [description]

Create and initialize a new codehooks project

Options:
-d, --debug show debug (verbose) information
--description A few words about this project
-n, --projectname Project name
-t, --teamid Add project to team with this id
-g, --ga-deploy Add Github Action for automatic deploy [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

init

$ codehooks init --help

Help output:

codehooks init [projectname] [space]

Initialise an existing project space in the current folder. Sets up default CRUD template in index.js.

Options:
-d, --debug show debug (verbose) information
-n, --projectname Project name
-s, --space Space name [default: "dev"]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

add

$ codehooks add --help

Help output:

codehooks add [space] [projectname] [restricted]

Add new space to project

Options:
-d, --debug show debug (verbose) information
--projectname [required]
-n, --space space name [required]
--restricted only team admins or owner can use if restricted [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

use

$ codehooks use --help

Help output:

codehooks use [name]

Set active space

Options:
-d, --debug show debug (verbose) information
--projectname [required]
-n, --name
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

info

$ codehooks info --help

Help output:

codehooks info [projectname] [space]

Show info about project and spaces

Options:
-d, --debug show debug (verbose) information
--projectname Active project [required]
--json Output info as JSON (not table) [boolean]
--space Only show info for this space [string]
-e, --examples Include cURL examples [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

stats

$ codehooks stats --help

Help output:

codehooks stats [project]

Show usage metrics for project spaces

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to query
--space Only show info for this space [string]
--json Output info as json [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

verify

$ codehooks verify --help

Help output:

codehooks verify [dir]

Compile code (defaults to current dir)

Options:
-d, --debug show debug (verbose) information
--dir [default: "."]
--space Select which space to access
-p, --projectname Select which project name to use
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

deploy

$ codehooks deploy --help

Help output:

codehooks deploy

Deploys current codehook folder

Options:
-d, --debug show debug (verbose) information
--dir [default: "."]
-s, --space Select which space to access
-p, --projectname Select which project name to use
--history Show deployment history
--rollback Undo last deployment, set previous as active
--json Output JSON format
--admintoken Use admin token authentication (use for CI)
--template Deploy a pre defined code template
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

undeploy

$ codehooks undeploy --help

Help output:

codehooks undeploy

Undeploy current codehook folder

Options:
-d, --debug show debug (verbose) information
--dir [default: "."]
-s, --space Select which space to access
-p, --projectname Select which project name to use
--json Output JSON format
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

log

$ codehooks log --help

Help output:

codehooks log [space] [tail] [follow] [context]

Show system logs for a space.

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project name to use
-s, --space Select which space to log
-t, --tail Chop log to n lines [default: 100]
-f, --follow Keep log stream open
-c, --context Filter log on: jobhooks, queuehooks, routehooks, datahooks, auth
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks log
codehooks log -f
codehooks coho log --tail 10
coho log --project 'pets-ff00' --space prod

count

$ codehooks count --help

Help output:

codehooks count [collection] [space]

Count objects in a collection in current space

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to query
-s, --space Select which space to query
-c, --collection Collection name [required]
--table Output info as table (not JSON) [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

query

$ codehooks query --help

Help output:

codehooks query [collection] [query] [space]

Run query on collection in current space

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to query
-s, --space Select which space to query
-q, --query Limit selection with a query expression [default: ""]
-n, --count Count query results
-c, --collection Collection name [required]
--delete Delete all items from query result
--update Patch all items from query result with JSON string '{...}' [string]
--replace Replace all items from query result with JSON string '{...}' [string]
--useindex Use an indexed field to scan data in query [string]
--start Start value for index scan [string]
--end End value for index scan [string]
--limit Limit query result [number]
--fields Comma separated list of fields to include [string]
--offset Skip items before returning data in query result [number]
--enqueue Add query result to queue topic [string]
--pretty Output data with formatting and colors
--reverse Scan index in reverse order
--table Output data as formatted table (not JSON) [boolean]
--csv Output data in CSV format [boolean]
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks query --collection pets --query 'name=Polly&type=Parrot'
codehooks query --collection pets --query 'name=/^po/'
codehooks query pets 'name=Polly' --useindex name --fields 'name,type'
codehooks q pets 'name=Polly&type=Parrot' --update '{"name": "Zilla"}'
codehooks q pets 'type=Fish' --delete
codehooks q pets 'type=Snake' --enqueue 'mytopic'

createindex

$ codehooks createindex --help

Help output:

codehooks createindex [collection] [index] [space]

Add field(s) to a query index

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection with indexes [required]
-i, --index Field to index [required]
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks createindex --collection pets --index name
codehooks idx pets name
codehooks idx pets -i name -i type -i 'price-in-dollar'

dropindex

$ codehooks dropindex --help

Help output:

codehooks dropindex [collection] [index] [space]

Remove field(s) from a query index

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection with indexes [required]
-i, --index Field to remove index for [required]
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks removeindex pets name
codehooks removeindex --collection pets --index 'name' --index 'type'

get

$ codehooks get --help

Help output:

codehooks get [key] [keyspace] [space] [json]

Retrieve key-value pair(s) from a space

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to query
-k, --key Key to match, or key* to fetch list [default: "*"]
--keyspace Keyspace to scan
--text Output info as text line [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks get 'my-value-one'
codehooks get 'my*'
codehooks get '*' --keyspace spacex

set

$ codehooks set --help

Help output:

codehooks set [key] [val]

Set key-value pair in a space

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use [string]
-s, --space Select which space to use [string]
--key Key to set [string] [required]
--val Value to set [string] [required]
--keyspace Keyspace to use [string]
--ttl Time to live in millis for value [number]
--json Output info as JSON (not table) [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks set 'my-value-one' 'foo'
codehooks set 'my-value-two' 'bar'
codehooks set 'session-4f51-9bed' 'OK' --keyspace 'spacex' --ttl 60000

del

$ codehooks del --help

Help output:

codehooks del [key] [keyspace] [space] [json]

Delete key-value pair in a space

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to use
--key Key to delete [required]
--keyspace Keyspace to use
--json Output info as JSON (not table) [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks del 'my-value-one'
codehooks del 'my-value-two' --keyspace 'spacex'

collection

$ codehooks collection --help

Help output:

codehooks collection [project] [output]

Show collections for space

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to query
-s, --space Select which space to query
--json JSON output format
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

createcollection

$ codehooks createcollection --help

Help output:

codehooks createcollection [collection]

Create a new collection

Options:
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection name [required]
--admintoken Use admin token authentication (use for CI)
-k, --cap Cap collection to max documents
-d, --capdelay show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks createcollection pets
codehooks createcollection logs --cap 5000

dropcollection

$ codehooks dropcollection --help

Help output:

codehooks dropcollection [collection]

Delete all data in collection and remove collection name

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection name [required]
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks dropcollection pets

add-schema

$ codehooks add-schema --help

Help output:

codehooks add-schema [collection] [schema]

Add a JSON schema to a collection

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection name [required]
--admintoken Use admin token authentication (use for CI)
-j, --schema Path to file with JSON schema for collection [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks add-schema --collection 'person' --schema './personSchema.json'

remove-schema

$ codehooks remove-schema --help

Help output:

codehooks remove-schema [collection]

Remove JSON schema for a collection

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection name [required]
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks remove-schema --collection 'person'

cap-collection

$ codehooks cap-collection --help

Help output:

codehooks cap-collection [collection] [cap] [capdelay]

Cap a collection

Options:
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection name [required]
--admintoken Use admin token authentication (use for CI)
-k, --cap Cap collection to max documents [default: 1000]
-d, --capdelay show debug (verbose) information [default: 1000]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks capcollection --collection 'temperature' --cap 10000

uncap-collection

$ codehooks uncap-collection --help

Help output:

codehooks uncap-collection [collection]

Remove cap on a collection

Options:
-d, --debug show debug (verbose) information
-p, --project Select which project to use
-s, --space Select which space to use
-c, --collection Collection name [required]
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks uncap-collection --collection 'temperature'

import

$ codehooks import --help

Help output:

codehooks import [filepath] [collection] [project] [space] [dryrun]

Import JSON or CSV data from file

Options:
-d, --debug show debug (verbose) information
-p, --project Project name [string] [required]
-s, --space A space in your project [string]
-c, --collection A collection in a Space [string] [required]
-f, --filepath File to import [string] [required]
--separator Field separator character, default is ',', also normal with '\t' or ';' [string] [default: ","]
--dryrun Test only, will not import any data [boolean] [default: false]
--rowcount Add a row count field to each imported record [boolean] [default: false]
--admintoken Use admin token authentication (use for CI)
--local Import data to local development server on port parameter [number]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
# shorthand
codehooks import ./myfile.csv mycollection

# explicit parameters
codehooks import --filepath ./myfile.csv --collection mycollection

# parameter shortcuts
codehooks import -f ./myfile.csv -c mycollection --local 3000

# Import data to local dev database
codehooks import -f ./myfile.csv -c mycollection --local 3000

export

$ codehooks export --help

Help output:

codehooks export [collection] [project] [space]

Export JSON or CSV data

Options:
-d, --debug show debug (verbose) information
-p, --project Project name [string] [required]
-s, --space a space name in your project [string]
--collection A collection in the space [string] [required]
-f, --filepath Filename to save export data [string]
--csv Export to CSV [boolean]
--admintoken Use admin token authentication (use for CI)
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

add-token

$ codehooks add-token --help

Help output:

codehooks add-token [readonly]

Add token to space

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
--space A space in your project [required]
--readonly [boolean] [default: false]
--description [string] [default: ""]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

remove-token

$ codehooks remove-token --help

Help output:

codehooks remove-token [token]

Remove token from space

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
--space A space in your project [required]
-t, --token [string] [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

set-env

$ codehooks set-env --help

Help output:

codehooks set-env [key] [value] [encrypted]

Set environment variable for space

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
--space A space in your project [required]
--encrypted [boolean] [default: false]
--key [string] [required]
--value [string] [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

remove-env

$ codehooks remove-env --help

Help output:

codehooks remove-env [key]

Remove environment variable from space

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
--space A space in your project [required]
-k, --key [string] [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

jwks

$ codehooks jwks --help

Help output:

codehooks jwks [url]

Set/replace JWKS endpoint for OAuth2 authentication. Set to "" (empty string) to remove.

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
--space A space in your project [required]
--url URL of JWKS endpoint (must be https) [string] [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

whitelist

$ codehooks whitelist --help

Help output:

codehooks whitelist [ip]

Add host to whitelist (use to restrict space access)

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
--space A space in your project [required]
--ip IP address which should be allowed access to space [string] [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

whitelist-remove

$ codehooks whitelist-remove --help

Help output:

codehooks whitelist-remove [ip]

Remove host from whitelist

Options:
-d, --debug show debug (verbose) information
--projectname Project name [required]
--space A space in your project [required]
--ip The IP address to remove from the whitelist. [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

completion

$ codehooks completion --help

Help output:

codehooks completion

Generate command completion script. Just add this to your .bashrc, .bash_profile, .zshrc (or similar) on *nix machines

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

remove-project

$ codehooks remove-project --help

Help output:

codehooks remove-project [projectname]

Remove the project

Options:
-d, --debug show debug (verbose) information
-p, --projectname Project name [string] [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

remove-space

$ codehooks remove-space --help

Help output:

codehooks remove-space [space] [projectname]

Remove space and data

Options:
-d, --debug show debug (verbose) information
--projectname Project name
--space A space in your project [required]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

admintokens

$ codehooks admintokens --help

Help output:

codehooks admintokens

Show active admintokens for account or team

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

add-admintoken

$ codehooks add-admintoken --help

Help output:

codehooks add-admintoken

Add admin token to account or team (for use with CI)

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

remove-admintoken

$ codehooks remove-admintoken --help

Help output:

codehooks remove-admintoken

Remove admin token from account or team

Options:
-d, --debug show debug (verbose) information
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

localserver

$ codehooks localserver --help

Help output:

codehooks localserver [port]

Run a local development server. Provides a local (JSON) database for test purpouses

Options:
-d, --debug show debug (verbose) information
-p, --port Listen on network port [number] [default: 3000]
-a, --auth Enable API key/JWKS for authentication [boolean] [default: false]
--apikey API key for client authentication, use when --auth is enabled [string] [default: "1234"]
--jwks JWKS endpoint, use when --auth is enabled [string]
--https Start server with https protocol enabled, using a self signed certificate [boolean]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]

Examples:
codehooks localserver
codehooks localserver --port 3000
codehooks localserver -p 3000 --auth --apikey 'secret-token'
codehooks localserver -p 8443 --https
codehooks localserver -p 3000 --auth --jwks 'https://<insert tenant name>.auth0.com/.well-known/jwks.json'
nodemon -w . -x 'codehooks localserver -p 3000'