unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Jacob Hrbek <kreyren@rixotstudio.cz>
To: guile-user@gnu.org
Subject: How can i make executable guile file to process command line arguments?
Date: Thu, 18 Aug 2022 14:01:56 +0000	[thread overview]
Message-ID: <6e5568cb-2924-010b-84b3-1fbf3482300b@rixotstudio.cz> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1854 bytes --]

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)))


[-- Attachment #1.2: publickey - kreyren@rixotstudio.cz - 1677db82.asc --]
[-- Type: application/pgp-keys, Size: 713 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

             reply	other threads:[~2022-08-18 14:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 14:01 Jacob Hrbek [this message]
2022-08-18 14:26 ` How can i make executable guile file to process command line arguments? Olivier Dion via General Guile related discussions
2022-08-18 17:58 ` Zelphir Kaltstahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e5568cb-2924-010b-84b3-1fbf3482300b@rixotstudio.cz \
    --to=kreyren@rixotstudio.cz \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).