Skip to content

A clojure/babashka library for building cli tools

Notifications You must be signed in to change notification settings

200ok-ch/shell-smith

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shell Smith

A Babashka library for handling configuration from multiple sources with a unified interface.

Features

  • Configuration management from multiple sources:
    • Command-line arguments (using docopt)
    • YAML configuration files
    • Environment variables
    • Default values
  • Automatic configuration merging with precedence
  • Simple and declarative configuration setup

Installation

Add to your deps.edn or bb.edn:

{:deps {200ok-ch/shell-smith {:git/url "https://github.com/200ok-ch/shell-smith"
                              :sha "current-sha"}}}

Usage

Basic Example

(ns my-app.core
  (:require [shell-smith.core :as smith]))

(def usage "
Usage:
  app [--port <port>]
  app (-h | --help)

Options:
  -h --help     Show this screen
  --port <port> Port number [default: 3000]
")

(def config
  (smith/config usage
                :name "myapp"))

Configuration Sources (in order of precedence)

  1. Command line arguments
  2. Environment variables (prefixed with uppercase app name)
  3. YAML configuration file
  4. Default values

Configuration File

Create a myapp.yml in your working directory:

port: 8080

Environment Variables

Environment variables should be prefixed with the uppercase app name:

MYAPP_PORT=9000

License

tbd.

About

A clojure/babashka library for building cli tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published