No description
  • Tree-sitter Query 49.4%
  • Scheme 44.8%
  • Makefile 2.7%
  • Shell 1.7%
  • M4 1.4%
Find a file
Gabriel Wicki 7d096d68d9
README: Add help to options.
For completeness and clarify.

* README.md (example): Add help texts.

Signed-off-by: Giacomo Leidi <therewasa@fishinthecalculator.me>
2026-07-29 22:11:32 +02:00
.guix/modules Release 0.2.0. 2026-06-16 22:41:29 +02:00
build-aux Add hall infrastructure. 2026-05-02 01:02:22 +02:00
doc arguments: Add structured subcommand support. 2026-06-16 22:39:53 +02:00
examples arguments: Add structured subcommand support. 2026-06-16 22:39:53 +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 arguments: Add structured subcommand support. 2026-06-16 22:39:53 +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 arguments: Add structured subcommand support. 2026-06-16 22:39:53 +02:00
ChangeLog.md Release 0.1.0. 2026-05-02 11:02:03 +02:00
configure.ac Release 0.2.0. 2026-06-16 22:41:29 +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.2.0. 2026-06-16 22:41:29 +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 README: Add help to options. 2026-07-29 22:11:32 +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)
      (help "Write output in ALL CAPS")
    (option
      (name 'language)
      (short #\l)
      (default "en")
      (help "Language of the output")
    (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.