Cli


Overview


Allow Actionhero developers to create new files in ./bin which can be run via the CLI. These commands will have access to a the Actionhero api and CLI arguments object within a run method.

You can create namespaces for commands by using folders. For example, a file in ./bin/redis/keys would be run via npx Actionhero redis keys

import { api, log, CLI } from "actionhero";

export class RedisKeys extends CLI {
  constructor() {
    super();
    this.name = "redis keys";
    this.description = "I list all the keys in redis";
    this.example = "actionhero keys --prefix actionhero";
    this.inputs = {
      prefix: {
        required: true,
        default: "actionhero",
        note: "the redis prefix for searching keys",
      },
    };
  }

  async run({ params }) {
    let keys = await api.redis.clients.client.keys(params.prefix);
    log("Found " + keys.length + "keys:");
    keys.forEach((k) => {
      log(k);
    });
  }
}

Syntax


actionhero CLI commands have:

  • name
  • description
  • example

Inputs for CLI commands have:

  • required (true/false)
  • default (string only)
  • note

These are sourced automatically by actionhero help, and the example above would return:

* redis keys
  description: I list all the keys in redis
  example: actionhero keys --prefix actionhero
  inputs:
    [prefix] (optional)
      note: the redis prefix for searching keys
      default: actionhero

    Solutions

    Actionhero was built from the ground up to include all the features you expect from a modern API framework.

    Open Source


    The Actionhero server is open source, under the Apache-2 license


    Actionhero runs on Linux, OS X, and Windows


    You always have access to the Actionhero team via Slack and Github



    Premium Training & Review


    We provide support for corporate & nonprofit customers starting at a flat rate of $200/hr. Our services include:


    • Remote training for your team
    • Code Reviews
    • Best Practices Audits
    • Custom plugin & Feature Development

    We have packages appropriate for all company sizes. Contact us to learn more.


    Premium Training & Review


    We provide support for corporate & nonprofit customers starting at a flat rate of $200/hr. Our services include:


    • Remote training for your team
    • Code Reviews
    • Best Practices Workshops
    • Custom plugin & Feature Development

    We have packages appropriate for all company sizes. Contact us to learn more.


    Enterprise


    For larger customers in need of a support contract, we offer an enterprise plan including everything in the Premium plan plus:


    • 24/7 access to core members of the Actionhero Team
    • Emergency response packages
    • Deployment support
    • ...and custom development against Actionhero’s core as needed.