1
0
Fork
You've already forked arguments
0
Parse command line arguments into structured objects in Guile
  • Tree-sitter Query 49.7%
  • Scheme 42.9%
  • Makefile 3.4%
  • Shell 2.2%
  • M4 1.8%
2026年05月06日 01:50:10 +02:00
.guix/modules Release 0.1.1. 2026年05月06日 01:50:10 +02:00
build-aux Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
doc doc: Add clearer documentation for argument-parser. 2026年05月06日 01:43:41 +02:00
examples doc: Add clearer documentation for argument-parser. 2026年05月06日 01:43:41 +02:00
m4 Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
scripts Add release script. 2026年05月02日 10:58:56 +02:00
tests Unsloppify. 2026年05月02日 00:52:03 +02:00
.dir-locals.el Unsloppify. 2026年05月02日 00:52:03 +02:00
.envrc Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
.gitignore Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
.guix-authorizations Add Guix channel definition. 2026年05月02日 01:17:25 +02:00
.guix-channel Add Guix channel definition. 2026年05月02日 01:17:25 +02:00
arguments.scm doc: Add clearer documentation for argument-parser. 2026年05月06日 01:43:41 +02:00
ChangeLog.md Release 0.1.0. 2026年05月02日 11:02:03 +02:00
configure.ac Release 0.1.1. 2026年05月06日 01:50:10 +02:00
COPYING Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
guix.scm Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
hall.scm Release 0.1.1. 2026年05月06日 01:50:10 +02:00
Makefile.am hall: Refresh. 2026年05月06日 01:47:59 +02:00
manifest.scm Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
pre-inst-env.in Add hall infrastructure. 2026年05月02日 01:02:22 +02:00
README.md doc: Update manual. 2026年05月04日 22:12:16 +02:00

argument parser for Guile Scheme

(arguments) is a library to parse command line arguments into structured objects, much like (ice-9 getopt-long) or (srfi srfi-37). Its API allows declaring arguments through a small DSL, then call a procedure to parse the command line into a structured object.

(use-modules (arguments))
(define parser
 (argument-parser
 #:program "greet"
 #:description "Say hello to someone."
 (flag
 (name 'shout?)
 (short #\s))
 (option
 (name 'language)
 (short #\l)
 (default "en"))
 (positional
 (name 'name))))
(define arguments (parse-arguments parser)))
(match-arguments arguments (shout? language name)
 (let ((msg (string-append "hello, " name)))
 (display (if shout? (string-upcase msg) msg))
 (newline)))

Installing arguments

You can get arguments from your favorite package manager:

Packaging status

Otherwise, you can use it from the main branch in a Guix shell with:

# Open a Guile REPL with arguments available
$ guix shell guile -f guix.scm -- guile
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,use(arguments)
scheme@(guile-user)> ,describe parse-arguments
Parse argv (a list of strings) according to parser, returning a
<parsed-arguments> record. By default, encountering --help/-h stops the
parsing, prints help and exits the process. Pass #:handle-help? #f to let the
&help-requested exception bubble up instead (this can be useful in tests and
embedders).

Building from source

Guix

To build with Guix you just need the guix command available on your system, then you can run:

guix build -f guix.scm

Autotools

To use autotools you need at least the following dependencies:

  • autoconf
  • automake
  • guile
  • make
  • pkg-config

then you can run:

autoreconf -vif
./configure
make

Guix channel

To configure Guix for using this repository as a channel, you need to create a .config/guix/channels.scm file with the following content:

(cons* (channel
 (name 'arguments)
 (url "https://codeberg.org/fishinthecalculator/arguments.git")
 (branch "main")
 ;; Enable signature verification:
 (introduction
 (make-channel-introduction
 "02eeca340178fd64ae27648683f2b9440f507302"
 (openpgp-fingerprint
 "50E1 7BE0 D210 C883 D675 3150 4A3D 07EF D05C 4045"))))
 %default-channels)

Otherwise, if you already have a .config/guix/channels.scm you can simply prepend this channel to the preexisting ones:

(cons* (channel
 (name 'arguments)
 (url "https://codeberg.org/fishinthecalculator/arguments.git")
 (branch "main")
 ;; Enable signature verification:
 (introduction
 (make-channel-introduction
 "02eeca340178fd64ae27648683f2b9440f507302"
 (openpgp-fingerprint
 "50E1 7BE0 D210 C883 D675 3150 4A3D 07EF D05C 4045"))))
 (channel
 (name 'nonguix)
 (url "https://gitlab.com/nonguix/nonguix")
 ;; Enable signature verification:
 (introduction
 (make-channel-introduction
 "897c1a470da759236cc11798f4e0a5f7d4d59fbc"
 (openpgp-fingerprint
 "2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5"))))
 %default-channels)

What is a Guix channel?

A channel is roughly the Guix equivalent of the AUR or container registries. It's a software repository providing Guix package and service definitions.

Contributing

All contributions are welcome. If you have commit access please remember to setup the authentication hook with

guix git authenticate --cache-key=channels/arguments --stats 02eeca340178fd64ae27648683f2b9440f507302 "50E1 7BE0 D210 C883 D675 3150 4A3D 07EF D05C 4045"

Running the test suite

make check

Building the manual

# Build the HTML manual
make html

Licence

Unless otherwise stated all the files in this repository are to be considered under the GPL 3.0 terms. You are more than welcome to open issues or send patches.