Codiga has joined Datadog!

Read the Blog·

Interested in our Static Analysis?

Sign up
← All posts
Daniel Strong Thursday, January 12, 2023

The Codiga CLI tool

Share

AUTHOR

Daniel Strong, Frontend Engineer

Daniel is a Frontend Engineer at Codiga.

He is a passionate frontend engineer, teacher, and learner. He has worked on or led several creative projects where he's grown his leadership, management, design, and programming skills.

See all articles

Why should you use the Codiga CLI tool?

Our goal was to make it simpler for users to engage with Codiga using the most fundamental tool available, their terminal.

We strongly believe in CLI tools at Codiga because they allow users to quickly and efficiency perform tasks in their terminal of choice.

We've made it incredibly easy to get started, so within a few minutes, you can have our new pre-push Git hook set up and running for future code pushes.

What is a CLI tool?

A command-line interface (CLI) tool is software that allows you to interact with it by typing commands in a text-based interface. These commands are typically entered into a command prompt or terminal window and are used to perform various tasks.

There are numerous terminals available, and some of the most popular are:

How to use the Codiga CLI tool?

Getting started with the Codiga CLI tool

You'll need to open your preferred terminal (Zsh, Fish or another) to get started.

The Codiga CLI tool is available through NPM, so you'll need to ensure you have Node.js installed.

You can check in your terminal if you have it installed by running the following command.

node -v

If you don't see a version number appear, you'll need to download Node.js.

Installing the Codiga CLI tool

There are two ways to install and interact with the Codiga CLI tool.

The most convenient method is to install it globally with the following command.

npm i -g @codiga/cli

You can then interact with the tool using the codiga command, as it's available globally.

codiga --help

Another method is using npx to download and execute a one-time command.

npx @codiga/cli --help

The outcome of these two --help commands will be the same.

Note: For the duration of this article, we will be using the shorthand codiga version for simplicity's sake. Just know that you can swap out codiga for npx @codiga/cli at any point and still achieve the same thing.

View @codiga/cli on NPM

What features does the Codiga CLI tool offer?

Analysis and report issues between two commits

To use Codiga's static analyzer to check for violations between two commits manually, you can use the following command.

codiga git-push-hook --remoteSha 123 --localSha 456

In the example above, 123 would be your remote SHA and 456 would be your local SHA. By passing these two commit SHA values to the script, we can check any modified files for errors or violations and report them to you.

If you'd like to learn how you can automate this task in a pre-push git hook, please refer to our documentation.

Adding a Codiga API token

Run the following command to get started on adding a Codiga API token.

codiga token-add

Checking a Codiga API token

You can run the following command to check your Codiga API token status.

codiga token-check

Deleting a Codiga API token

To delete a Codiga API token from your machine, please run the following.

codiga token-delete

Note: this will only delete the token from your local machine. If you would like to delete a Codiga API token completely, you can do that on our API token page

Help

Please run the following command to view a list of all commands and some information regarding them.

codiga --help

To view more information for a specific command, run one of the following commands.

# git push hook
codiga git-push-hook --help
# token add
codiga token-add --help
# token check
codiga token-check --help
# token delete
codiga token-delete --help

Summary

We're always striving to improve our product and make your life as developers easier. If you desire a specific command, find any bugs, or just want to stay up-to-date on the new Codiga CLI tool, please follow or check out the GitHub repo or the NPM package.

Related Links

Are you interested in Datadog Static Analysis?

Sign up