unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* xdgdirs 1.0
@ 2013-09-05 10:42 Thien-Thi Nguyen
  2013-09-07  8:36 ` Andy Wingo
  0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2013-09-05 10:42 UTC (permalink / raw)
  To: guile-sources; +Cc: guile-user


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

Greetings earthlings,

I'm contemplating adding XDG basedirs support to GNU Alive and GNU
Serveez, so the obvious approach is classic modularity: write the
functionality once and somehow make it available.  It's no big deal to
start w/ ‘define-module’, but then the questions begin:

 - What is a good module name?
 - What package does it belong to?
 - Does the use case justify keeping all this code in memory?
 - Is this really "write once"?
   - What about Lisp programs?
   - What about programs (in any language) that can ‘read’ sexps?

The functionality is basically using ‘getenv’ and ‘parse-path’ to
produce easily-serialized data (strings and lists of strings), amenable
to piping and other textual manipulations.  So, why not a standalone
program?

As to the packaging, for a bit i mulled over a "XDG Utils" package with
only one program to start, but that would be succumbing to my bad habit
of overengineering things, so i'm glad to say that bit was short-lived.

Anyway, here it is:

[-- Attachment #1.2: xdgdirs --]
[-- Type: application/x-scheme, Size: 4386 bytes --]

[-- Attachment #1.3: Type: text/plain, Size: 442 bytes --]


Installation is simple:

 # install xdgdirs /usr/local/bin

The program supports ‘--help’ and ‘--version’, which must suffice in
lieu of proper documentation, for now.  Maybe some future release...

-- 
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     => nil

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: xdgdirs 1.0
  2013-09-05 10:42 xdgdirs 1.0 Thien-Thi Nguyen
@ 2013-09-07  8:36 ` Andy Wingo
  2013-09-07  9:10   ` Thien-Thi Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Wingo @ 2013-09-07  8:36 UTC (permalink / raw)
  To: Thien-Thi Nguyen; +Cc: guile-user, guile-sources

Just a bunch of random things.  No opinion about module names, etc :)

On Thu 05 Sep 2013 12:42, Thien-Thi Nguyen <ttn@gnu.org> writes:

> (define mentioned?
>   (let ((cl (command-line)))
>     (lambda (opt)
>       (member opt cl))))

You could do this as (cute member <> (command-line)), having imported
srfi-26.

> (cond ((mentioned? "--help")
>        (use-modules (ice-9 documentation))
>        (fso "~A~%" (file-commentary (car (command-line))))
>        (exit #t)))

Here I think "when" is much more readable.  Also, you can use
"(current-file-name)" for a more reliable way to get the current file
name.

> (cond ((mentioned? "--version")
>        (fso "xdgdirs ~A~%~A~%" VERSION COPYRIGHT)
>        (fso "~A ~A~%~A~%~A~%"
>             "License GPLv3+: GNU GPL version 3 or later"
>             "<http://gnu.org/licenses/gpl.html>"
>             "This is free software: you are free to change and redistribute it."
>             "There is NO WARRANTY, to the extent permitted by law.")
>        (exit #t)))

You can use (ice-9 command-line)'s version-etc.

Regards,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: xdgdirs 1.0
  2013-09-07  8:36 ` Andy Wingo
@ 2013-09-07  9:10   ` Thien-Thi Nguyen
  0 siblings, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2013-09-07  9:10 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-user, guile-sources

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

() Andy Wingo <wingo@pobox.com>
() Sat, 07 Sep 2013 10:36:38 +0200

   > (define mentioned? ...)

   You could do this as (cute member <> (command-line)),
   having imported srfi-26.

   > (cond ((mentioned? "--help") ...)

   Here I think "when" is much more readable.  Also, you can use
   "(current-file-name)" for a more reliable way to get the current
   file name.

   > (cond ((mentioned? "--version") ...)

   You can use (ice-9 command-line)'s version-etc.

Thanks for the tips.  I'll try to keep these in mind.

-- 
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     => nil

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-07  9:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-05 10:42 xdgdirs 1.0 Thien-Thi Nguyen
2013-09-07  8:36 ` Andy Wingo
2013-09-07  9:10   ` Thien-Thi Nguyen

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