Skip to content

startdevx/dx-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

How to use DX CLI?

📘 Overview

DX CLI is your developer experience companion. A command-line tool that helps automate and standardize recurring setup and configuration tasks across your organization.

This guide explains:

  • How to use the built-in DX CLI commands.
  • How to create your own custom CLI and make it available to your peers.

📖 Commands

dx [-h|-H|--help]

Display all available commands in the CLI.

dx [-v|-V|--version]

Show the current version of DX CLI.

dx ai

Use AI to answer your configuration-related questions and automatically set up your local environment.

dx update

Update the DX CLI core component along with all organization-managed features.

🛠️ Creating a Custom CLI

💡 Why create a custom CLI?

When new engineers join your team, they often face a maze of setup steps: reading documentation, configuring tools, and adjusting their environment. A custom CLI automates these repetitive tasks, making onboarding fast and seamless.

For example, you can script:

  • Maven setup with custom proxies and mirrors
  • Certificate management within a Java truststore
  • And more!

All these can be distributed to all your peers within your organization through DX CLI packages.

🧭 Prerequisites

Before creating your own CLI, make sure you:

  • Have write access to your organization’s DX CLI packages repository.
  • Follow your organization's contribution guidelines.

🪄 Example: Create a helloworld CLI

We’ll create a simple command that prints:

C:\Users\startdevx>helloworld
Hello world Kevin!

📁 Step 1 - Create the folder structure

In the root directory of your DX CLI packages repository, create a new folder named helloworld with the following structure:

helloworld/
├── config.json
└── start.ps1

In the config.json file, the version and description fields are used for displaying information when using dx -h. Copy/paste the following content in the config.json file:

{
    "version": "0.0.1",
    "description": "Display 'Hello world <username>!' message on your command prompt"
}

In the start.ps1, add your script logic. Copy/paste the following content in start.ps1 file:

Write-Host "Hello world $Env:USERNAME!"

⚙️ Step 2 - Create a CLI entrypoint

If it doesn't exist, create a .bin/ root folder and create a new .bat file named after your target CLI - in this example, helloworld.bat and copy/paste the following content in the helloworld.bat file:

@echo OFF

set current_location=%~dp0
set cli_folder=%~n0
set command=%*

powershell -NoProfile -ExecutionPolicy bypass -File "%current_location%..\%cli_folder%\start.ps1" %command%

You can rename start.ps1 to any filename. Just remember to update its reference inside the .bat file.

🚀 Step 3 - Publish and test

Once your CLI works locally:

  • Commit and merge your changes to the main branch.
  • Users can run dx update to fetch the latest packages.
  • Your new helloworld command will be ready to use!

🧠 Step 4 - Use other scripting languages

Want to use another scripting language like Python? Just modify the .bat launcher to call the appropriate file:

@echo OFF

set current_location=%~dp0
set cli_folder=%~n0
set command=%*

python "%current_location%..\%cli_folder%\start.py" %command%

🪙 Credits

DX CLI is an open-source solution available on GitHub, crafted by Start DevX organization.

About

DX CLI core

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks