Using the Command-Line Interface (CLI)

NanoAPI's CLI, napi, is a powerful tool that allows you to interact with your software projects in a more efficient and clear way.

For now, it exposes three simple commands.

Commands

napi split <entrypoint>

Args:
 - entrypoint: The entrypoint file for the codebase as a path, e.g. ./src/index.js

Based on the codebase annotations, this command will split the codebase into smaller, more manageable pieces. This is useful for large codebases that are difficult to understand.

Note: This command works off of comment-based annotations for now. We are working on a more robust solution for the future.

Annotated endpoints look like the following:

// @nanoapi path:/random method:GET
app.get('/random', (req, res) => {
  res.send(Math.random());
});

napi ui [entrypoint]

Options:
  - entrypoint: The entrypoint file for the codebase as a path, e.g. ./src/index.js. 
    This is optional, and if not set can be set through the UI directly.

This command will open the NanoAPI UI in your default browser. The UI is a powerful tool that allows you to visualize your codebase and understand it better.

Learn more about how to use it in the UI documentation.

napi <platform> annotate <entrypoint> [--token=<key>]

Note: This command exists to simplify the process of adding annotations to your codebase as an in-between measure for large codebases. As doing this programmatically is on our roadmap, this feature will likely be deprecated in the future.

Args:
  - platform: The AI platform you are using to generate annotations with, 
    e.g. openai, gpt3, etc. (Only openai is supported for now)
  - entrypoint: The entrypoint file for the codebase as a path, e.g. ./src/index.js
Options:
  - token: The API key for the platform you are using

This command will generate annotations for your codebase based on the platform you choose. This is useful for adding annotations to your codebase quickly and efficiently.

By using a set of prompts and an OpenAI key, we are able to generate annotations for your codebase. Please keep in mind that if you do not wish for your codebase to be sent to OpenAI, you should not use this command.

To generate an OpenAI key, please visit the OpenAI website.

Updates

We are adding new features all the time to this CLI. Please check our Github repository for the latest roadmap, updates, and to contribute to the project.