Auxilium Logo

auxilium.sh

POSIX Shell Argument Parsing Library

Features

Easy Argument Definition

Add arguments with long names (--arg) and short options (-a) in a simple, intuitive way.

Multiple Argument Types

Support for strings, boolean flags, positional arguments, and subcommands.

Auto Help Generation

Automatically generate comprehensive --help messages with descriptions and usage.

Shell Completion

Generate autocompletion scripts for Bash and Zsh shells.

POSIX Compatible

Works across different shells (bash, zsh, dash, ksh) for maximum portability.

Choice Validation

Validate argument values.

Installation

Installation
$ # Download and install auxilium.sh
$ sudo mkdir -p /usr/local/lib/auxilium
$ sudo cp auxilium.sh /usr/local/lib/auxilium/

                        

Usage

Basic Usage
#!/bin/sh
# Source the library
. /usr/local/lib/auxilium/auxilium.sh

# Initialize
auxilium_init "myapp" -m "My application description"

# Add arguments
auxilium_add "verbose" -s v -t opt -m "Enable verbose mode"
auxilium_add "config" -s c -d "/etc/app.conf" -m "Config file"
auxilium_add "format" -l "json|xml|yaml" -m "Output format"

# Parse arguments
auxilium_parse "$@"

# Use parsed values
echo "Config: $AUXILIUM_ARG_CONFIG"
[ "$AUXILIUM_ARG_VERBOSE" = "1" ] && echo "Verbose mode"

# Cleanup
auxilium_close

Examples

Help Output
Description:
    My application description

Usage: myapp [-h|--help] [-v|--verbose] [-c|--config CONFIG] [--format FORMAT]

Optional Arguments:
    -h|--help                      This help message
    -v|--verbose                   Enable verbose mode
    -c|--config CONFIG             Config file
                                   Default: /etc/app.conf
    --format FORMAT                Output format
                                   Choice: json|xml|yaml

auxilium.sh

Bibliothèque POSIX pour Parser les Arguments Shell

Fonctionnalités

Définition d'Arguments Facile

Ajoutez des arguments avec des noms longs (--arg) et des options courtes (-a) facilement.

Types d'Arguments Multiples

Support des chaînes, booléens, arguments positionnels et sous-commandes.

Génération d'Aide Automatique

Génère automatiquement des messages --help complets avec descriptions et usage.

Autocomplétion Shell

Génère des scripts d'autocomplétion pour les shells Bash et Zsh.

Compatible POSIX

Fonctionne sur différents shells (bash, zsh, dash, ksh) pour une portabilité maximale.

Validation de Choix

Valide les valeurs d'arguments.

$ ./installer.sh

Installation
$ # Télécharger et installer auxilium.sh
$ sudo mkdir -p /usr/local/lib/auxilium
$ sudo cp auxilium.sh /usr/local/lib/auxilium/
                        

$ cat utilisation.sh

Utilisation de Base
#!/bin/sh
# Sourcer la bibliothèque
. /usr/local/lib/auxilium/auxilium.sh

# Initialiser
auxilium_init "monapp" -m "Description de mon application"

# Ajouter des arguments
auxilium_add "verbose" -s v -t opt -m "Activer le mode verbeux"
auxilium_add "config" -s c -d "/etc/app.conf" -m "Fichier de config"
auxilium_add "format" -l "json|xml|yaml" -m "Format de sortie"

# Parser les arguments
auxilium_parse "$@"

# Utiliser les valeurs parsées
echo "Config: $AUXILIUM_ARG_CONFIG"
[ "$AUXILIUM_ARG_VERBOSE" = "1" ] && echo "Mode verbeux"

# Nettoyage
auxilium_close

$ ./exemples/demo.sh --help

Sortie d'Aide
Description:
    Description de mon application

Usage: monapp [-h|--help] [-v|--verbose] [-c|--config CONFIG] [--format FORMAT]

Arguments Optionnels:
    -h|--help                      Ce message d'aide
    -v|--verbose                   Activer le mode verbeux
    -c|--config CONFIG             Fichier de config
                                   Défaut: /etc/app.conf
    --format FORMAT                Format de sortie
                                   Choix: json|xml|yaml