/dtr-cli

DTR CLI is an open source developer helping CLI tool build on typescript

Primary LanguageTypeScript

DTR CLI tool

DTR - CLI thumbnail

  1. Introduction
  2. Installation
  3. Usage
  4. Commands
  5. Configuration
  6. Global Configuration
  7. Install for development

Introduction

DTR-CLI is a command-line interface tool designed to help manage and interact with code files in your directory. It includes various commands to initialize configurations, add code files, create new code files, read existing files, delete files, and manage boilerplate templates.

Installation

DTR-CLI already published on npm

npm install -g dtr-cli

For Linux and Mac user

  1. Install package from npm:

    sudo npm install -g dtr-cli
  2. Find dtr-cli global location:

    which dtr # it will return like `/usr/local/bin/dtr`
    cd /usr/local/bin
  3. Show dtr-cli all files:

    ls -la

    It will return something like this:

    lrwxrwxrwx 1 root root 42 Jul 17 23:09 dtr -> ../lib/node_modules/dtr-cli/build/index.js

    Go to this node_modules folder:

    cd ../lib/node_modules/
  4. Add read write permission:

    sudo chmod 775 -R dtr-cli/

Now you are ready to use dtr-cli by dtr command

Usage

After installation, you can use the dtr command followed by the specific subcommand.

dtr <command> [argument] [flags]

Commands

Init command

Initialize the dtr-config.json configuration file.

dtr init

Flags

  • -c, --code <codeFolder>: Path for the code file directory. This is optional. This is optional.

Add command

Add a code file to your directory.

dtr add

Arguments

  • [codeName]: Name of the code file you want to add. This is optional. This is optional.

Create command

Create a new code file.

dtr create

Argument

  • [codeName]: Name of the code file. This is optional.

Flags

  • -f, --from <codeFrom>: Source of the code file. Accepts 'local' | 'internet'. This is optional.
  • -u, --url <internetURL>: GitHub code URL if you select 'codeFrom' as 'internet'. This is optional.
  • -p, --path <localPath>: Current directory file path if you select 'codeFrom' as 'local'. This is optional.

Read command

Read all code files.

dtr read

Argument

  • [codeName]: Name of the code file. This is optional.

Delete command

Delete a global code file.

dtr delete

Create template command

Create a new boilerplate template.

dtr create-template

Argument

  • [templateName]: Name of the template. This is optional.

Options

  • -s, --source <source>: Source folder of the template. This is optional.

Template command

Add a boilerplate template in the current directory.

dtr template

Argument

  • [templateName]: Name of the template. This is optional.

Configuration

The dtr-config.json file will be initialized by init command. This file stores the configuration settings of current working directory.

Example dtr-config.json:

{
  "codeFolder": "code", // code folder name
  "addedCode": [
    {
      "fileName": "",
      "path": ""
    }
    // all code files
  ]
}

Global configuration

The configData.json file will be initialized in the global root directory. This file stores the configuration settings for the CLI tool.

Example configData.json:

{
  "allFiles": [
    {
      "fileName": "",
      "path": ""
    }
    // all code files
  ],
  "allTemplates": [
    {
      "templateName": "",
      "templateFolder": ""
    }
    // all templates
  ]
}

Install for development

  1. Clone the repository:

    git clone https://github.com/saiful7778/dtr-cli.git
    cd dtr-cli
  2. Install dependencies:

    npm install
    # or
    yarn install
    # or
    pnpm install
    # or
    bun install

Note: Here I use bun you can any of them

  1. Build the package:

    npm run build
    # or
    yarn run build
    # or
    pnpm run build
    # or
    bun run build