Skip to content

Latest commit

 

History

History
120 lines (88 loc) · 2.39 KB

File metadata and controls

120 lines (88 loc) · 2.39 KB

Getting Started

This guide helps you create your first CLI application with radp-bash-framework.

Prerequisites

  • Bash 4.3+
  • GNU getopt (auto-installed if missing)
  • yq (auto-installed if missing)

Installation

Homebrew (macOS)

brew tap xooooooooox/radp
brew install radp-bash-framework

Script Install

curl -fsSL https://raw.githubusercontent.com/xooooooooox/radp-bash-framework/main/install.sh | bash

See Installation Guide for more options.

Create Your First CLI

1. Generate a Project

radp-bf new myapp
cd myapp
./bin/myapp --help

This creates:

myapp/
├── bin/myapp                 # Entry point
├── src/main/shell/
│   ├── commands/             # Command implementations
│   │   ├── hello.sh          # myapp hello
│   │   └── version.sh        # myapp version
│   └── config/
│       ├── config.yaml       # Configuration
│       └── _ide.sh           # IDE support
├── .radp-cli/                # Scaffold metadata
└── install.sh                # Installer script

2. Add a Command

Create src/main/shell/commands/greet.sh:

# @cmd
# @desc Greet someone
# @arg name!              Required argument
# @flag -l, --loud        Shout the greeting

cmd_greet() {
  local name="$1"
  local msg="Hello, $name!"

  if [[ "${opt_loud:-}" == "true" ]]; then
    echo "${msg^^}"
  else
    echo "$msg"
  fi
}

3. Run Your Command

$ ./bin/myapp greet World
Hello, World!

$ ./bin/myapp greet --loud World
HELLO, WORLD!

4. Add Subcommands

Create directories for command groups:

commands/
├── db/
│   ├── migrate.sh    # myapp db migrate
│   └── seed.sh       # myapp db seed
└── hello.sh          # myapp hello

5. Add Configuration

Edit config/config.yaml:

radp:
  extend:
    myapp:
      api_url: https://api.example.com

Access in code:

echo "$gr_radp_extend_myapp_api_url"

Next Steps