Skip to main content

Command-line tool for creating and managing DBBasic apps

Project description

dbbasic-cli

Command-line tool for creating and managing DBBasic apps.

Philosophy

"Tools, not frameworks. Scripts, not magic."

The Unix way is small composable tools. CGI was successful because it was just scripts in a directory. No build step, no generators, no magic.

Design Principles

  1. Unix Tools First: Use git, cp, sed - not custom generators
  2. Scripts Over Frameworks: CLI is thin wrapper around standard tools
  3. Optional: Can use dbbasic without CLI
  4. Extensible: Modules can add commands (like Django's manage.py)
  5. No Magic: Everything is visible, debuggable

Installation

pip install dbbasic-cli

Quick Start

# Create a new blog app
dbbasic new blog myblog

# Enter the directory
cd myblog

# Install dependencies
pip install -r requirements.txt

# Run it
python app.py

Core Commands

dbbasic new <type> <name>

Creates a new app from a template.

dbbasic new blog myblog
dbbasic new api myapi
dbbasic new shop myshop

Available templates:

  • blog - WordPress-like blog (~200 lines)
  • microblog - Twitter-like social app (~300 lines)
  • api - REST API (~150 lines)
  • shop - E-commerce (~400 lines)
  • intranet - Basecamp-like project manager (~500 lines)

dbbasic list

Lists all available templates.

dbbasic list

dbbasic run

Runs the app (optional, just python app.py works too).

dbbasic run

# With options
dbbasic run --port 8000

dbbasic test

Runs tests.

dbbasic test

Module Commands

Modules can add their own commands! For example:

# From dbbasic-queue
dbbasic queue:worker    # Start queue worker
dbbasic queue:stats     # Show queue statistics

# From dbbasic-logs
dbbasic logs:tail       # Tail application logs
dbbasic logs:search     # Search logs

# From dbbasic-accounts
dbbasic accounts:create # Create user account
dbbasic accounts:list   # List all accounts

Standard Directory Structure

Every dbbasic app follows this structure:

myapp/
├── app.py              # Main application file
├── data/               # TSV data files
│   ├── posts.tsv
│   └── users.tsv
├── templates/          # HTML templates
│   ├── layout.html
│   ├── home.html
│   └── posts/
│       ├── list.html
│       ├── show.html
│       └── edit.html
├── static/             # CSS, JS, images
│   ├── css/
│   ├── js/
│   └── img/
├── tests/              # Test files
│   └── test_app.py
├── requirements.txt    # Python dependencies
└── README.md           # Documentation

Extending with Module Commands

Modules can provide CLI commands by including a cli.py:

# dbbasic_yourmodule/cli.py

def hello_command(args):
    """Say hello"""
    print("Hello from your module!")

def stats_command(args):
    """Show statistics"""
    print("Module statistics here...")

# Register commands
COMMANDS = {
    'yourmodule:hello': hello_command,
    'yourmodule:stats': stats_command,
}

Now these work automatically:

dbbasic yourmodule:hello
dbbasic yourmodule:stats

No CLI? No Problem!

You don't need the CLI to use dbbasic. The "pure Unix way":

# Clone an example
git clone https://github.com/askrobots/dbbasic-examples
cp -r dbbasic-examples/blog myblog
cd myblog
rm -rf .git

# Run it
python app.py

The CLI is just a convenience wrapper around standard Unix commands.

Comparison

CGI Way (1993)

mkdir myblog
cd myblog
cat > index.cgi << 'EOF'
#!/bin/bash
echo "Content-Type: text/html"
echo ""
echo "<h1>My Blog</h1>"
EOF
chmod +x index.cgi

Rails Way (2005)

rails new blog  # Generates 50+ files
rails g model Post
rails g controller Posts

dbbasic Way (2025)

dbbasic new blog myblog  # Optional convenience
# OR just: git clone + cp + python app.py

Development

# Clone the repo
git clone https://github.com/askrobots/dbbasic-cli
cd dbbasic-cli

# Install in development mode
pip install -e .

# Test it
dbbasic help

Size

  • Core CLI: ~200 lines
  • Total: ~250 lines with packaging
  • Compare to:
    • Rails CLI: ~10,000+ lines
    • Django CLI: ~5,000+ lines
    • CGI: 0 lines (no CLI needed)

License

MIT

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbbasic_cli-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbbasic_cli-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file dbbasic_cli-1.0.0.tar.gz.

File metadata

  • Download URL: dbbasic_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.1

File hashes

Hashes for dbbasic_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4c6ab4600d9a7d97d24863617e834d650fdeebf6c73ef3eea3b1415dbd70a625
MD5 72fa05f591a4872bff3e9b50c12e627f
BLAKE2b-256 0f32434d6b267d3a177fad459ac626e2e265ff288cdfb2e9ea4a423c47028bd7

See more details on using hashes here.

File details

Details for the file dbbasic_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dbbasic_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.1

File hashes

Hashes for dbbasic_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cda5d2f7ecb44f5e3c4ee65e53a55995bbdfb84fcc02d7b1b8510196c5f6686
MD5 f8d2e66d0d1794a7e70bf40ed7bc58c8
BLAKE2b-256 fc75523f98fb9967e76a2bd473f2ed88f573c0b98cee29691b12c91dbfec1bbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page