[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How can i make executable guile file to process command line arguments?
From: |
Jacob Hrbek |
Subject: |
How can i make executable guile file to process command line arguments? |
Date: |
Thu, 18 Aug 2022 14:01:56 +0000 |
I have this file which i use to interact with a version controlled
repository similar to a Makefile.
How can i make it work with e.g. `./file.scm echo wheee` -> Will execute
the `(define (echo msg) ...)` and output `wheee` in the terminal?
FWIW preferably i want it to work like `./file.scm echo whee build` so
that it would output `wheee` and then ran the `(define (build) ...)`
task too..
#!/usr/bin/env sh
exec guile -s "$0" "$@"
!#
;;; This file is used to interact with the project
;;; ==== [START] TO BE INCLUDED IN A LIBRARY [START] ==== ;;;
;; Get path to the current filename
(define-public %repo-root (dirname (current-filename)))
;;; ==== [STOP] TO BE INCLUDED IN A LIBRARY [STOP] ==== ;;;
;; FIXME-QA(Krey): We need to define an alternative to `(define
(task)...)` to be more workable and faster to write
;;; Tasks
;; DESIGN(Krey): Build the system configuration
(define (build)
(system* "guix"
"system"
"build"
(string-append %repo-root "/config.scm")))
;; DESIGN(Krey): Deploy the system configuration on the current system
(define (deploy)
(system* "guix"
"system"
"reconfigure"
(string-append %repo-root "/config.scm")))
;; DESIGN(Krey): Build the bare minimal image for rockpro64
(define (tools-minimal-rockpro64)
(system* "guix"
"system"
"--system=aarch64-linux"
"image"
(string-append %file-root "/config.scm")))
;; Processing of cli arguments
(define (echo msg) (system* "echo" msg))
;; DESIGN(Krey): Expecting to process the command-line args here
;; HOTFIX(Krey): Didn't figure out how to do it yet, so currently
hard-coding
; deploy
;(quote (cdr (command-line)))
;;(match (command-line) ((_ "build") (build)))
publickey - kreyren@rixotstudio.cz - 1677db82.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature
- How can i make executable guile file to process command line arguments?,
Jacob Hrbek <=