Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

makitso

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makitso

A Framework for building composable interactive commandline apps

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Makitso

A Framework for building composable interactive commandline apps.

With Makitso you can build interactive commandline apps with simple plugin modules which define commands, a property schema, and/or storage connectors.

The schema defines context properties, the storage to use, and a prompt for collecting the value of the property.

{
  schema: {
    my: {
      name: {
        store: "file",
        prompt: {
          type: "input",
          name: "name",
          message: `Enter your {variant} name ...`
        }
      }
    }
  }
}

Commands define the command arguments format, help description and an action function.

Commands can be grouped using the config.command property for all commands in the plugin, and with object nesting within the plugin. Autocomplete will be supported for each of the command levels.

Commands can also provide a "choices" property which will allow autocomplete to provide available options for the command.

Command action functions receive a context instance which gives access to properties handled by other plugins. If a required property has not already been set then the plugin which is handling it will prompt the user to enter it and then return the entered value.

{
  commands: {
    set: {
      args: "prop value",
      description: "Set a context value",
      action: (context, { prop, value }) => context.set(prop, value)
    },
    printName: {
      description: "Print your name",
      action: async (context) => {
        const firstName = await context.get("my.name.first");
        const lastName = await context.get("my.name.last");
        console.log(`${firstName} ${lastName}`);
      }
    },
    debug: {
      on: {
        description: "Turn on debugging",
        action: async context => console.log("Debug On")
      },
      off: {
        description: "Turn off debugging",
        action: async context => console.log("Debug Off");
      }
    },
    dump: {
      store: {
        args: "storeId",
        description: "Dump the store",
        choices: {
          storeId: ({ context }) => context.listStores()
        },
        action: async (context, { storeId }) => {
          const store = await context.getStore(storeId);
          console.log(JSON.stringify(await store.read(), null, 2));
        }
      }
    },
  },
  config: {
    command: "demo"
  }
}

Usage

$ makitso
? Makitso> demo printName
? Enter your first name ... Jason
? Enter your last name ... Galea
Jason Galea
? Makitso> demo printName
Jason Galea
? Makitso>

See the builtin app for an example or install this module globally and try it for yourself.

$ yarn global add makitso
$ makitso

Makitso uses inquirer, and a modified version of inquirer-command-promt, and some custom plumbing to hook them up to a central context module backed by session (memory), file, and secure (keychain) context storage.

FAQs

Package last updated on 19 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc