- Tree-sitter Query 49.7%
- Scheme 42.9%
- Makefile 3.4%
- Shell 2.2%
- M4 1.8%
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:
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.