summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Conchillo FlaquƩ <aconchillo@gmail.com>2022-01-20 23:41:36 -0800
committerAleix Conchillo FlaquƩ <aconchillo@gmail.com>2022-01-21 01:09:11 -0800
commit4b6d08b2c3fcc6545f0eaea49194792ec3e7e9b5 (patch)
tree2900b478f495c1156fde2f11cdad2641bd5209fc
initial commitv0.0.0
-rw-r--r--Makefile29
-rw-r--r--README.org32
-rw-r--r--examples/choices.gs8
-rwxr-xr-xgas59
-rw-r--r--gas.gifbin0 -> 294983 bytes
5 files changed, 128 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..32beb0b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,29 @@
+# Copyright (C) 2022 Aleix Conchillo Flaque <aconchillo@gmail.com>
+#
+# This file is part of gas.
+#
+# gas is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# gas is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with gas. If not, see https://www.gnu.org/licenses/.
+
+DESTDIR:=/usr/local
+
+all:
+ @echo "Try to run 'make install'"
+
+install:
+ chmod +x gas
+ install -d '$(DESTDIR)/bin'
+ install -c gas '$(DESTDIR)/bin'
+
+uninstall:
+ rm -f '$(DESTDIR)/bin/gas'
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..cefdc59
--- /dev/null
+++ b/README.org
@@ -0,0 +1,32 @@
+
+* gas
+
+gas is a tool that allows writing [[https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/][Mac Scripting]] applications with [[https://github.com/aconchillo/guilescript][GuileScript]].
+
+This project is in a very primitive state since it depends on GuileScript which
+is totally a work-in-progress. I actually started GuileScript in order to be
+able to create gas after seeing [[https://twitter.com/zaneshelby/status/1477988369154121734?s=20][obb]], a very cool ClojureScript project.
+
+* Installation
+
+You can clone the repo and run:
+
+#+BEGIN_EXAMPLE
+$ make install
+#+END_EXAMPLE
+
+But it's probably better if you install it through [[https://github.com/aconchillo/homebrew-guile][Guile Homebrew]]:
+
+#+BEGIN_EXAMPLE
+$ brew install aconchillo/guile/gas
+#+END_EXAMPLE
+
+* Examples
+
+There's only one example right now:
+
+#+BEGIN_EXAMPLE
+$ gas examples/choices.gs
+#+END_EXAMPLE
+
+[[./gas.gif]]
diff --git a/examples/choices.gs b/examples/choices.gs
new file mode 100644
index 0000000..f1f2773
--- /dev/null
+++ b/examples/choices.gs
@@ -0,0 +1,8 @@
+;; -*- mode: scheme; coding: utf-8; -*-
+
+(define choices #("Bread" "Pudding" "Cake"))
+
+(define app (Application.currentApplication))
+(set! app.includeStandardAdditions #t)
+
+(.chooseFromList app choices)
diff --git a/gas b/gas
new file mode 100755
index 0000000..bbeb914
--- /dev/null
+++ b/gas
@@ -0,0 +1,59 @@
+#!/bin/sh
+# -*-scheme-*-
+exec guile -e "(@@ (gas) main)" -s "$0" "$@"
+!#
+
+;;; (gas) --- Guile/Apple/Script
+
+;; Copyright (C) 2022 Aleix Conchillo Flaque <aconchillo@gmail.com>
+;;
+;; This file is part of gas.
+;;
+;; gas is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; gas is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with gas. If not, see https://www.gnu.org/licenses/.
+
+;;; Commentary:
+
+;; Guile/Apple/Script
+
+;;; Code:
+
+(define-module (gas)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 textual-ports)
+ #:use-module (language guilescript compile))
+
+(define (compile-gas filename)
+ (let ((js (compile-file filename))
+ (port (mkstemp "/tmp/gas-XXXXXX")))
+ (chmod port #o700)
+ (put-string
+ port
+ (string-append "#!/usr/bin/osascript -l JavaScript\n\n" js))
+ port))
+
+(define (run-gas filename)
+ (let* ((port (compile-gas filename))
+ (tmpfile (port-filename port)))
+ (close-port port)
+ (system tmpfile)
+ (delete-file tmpfile)))
+
+(define main
+ (match-lambda
+ ((_)
+ (display "Usage: gas filename.gs")
+ (newline)
+ (exit 1))
+ ((_ filename) (run-gas filename))))
diff --git a/gas.gif b/gas.gif
new file mode 100644
index 0000000..e59bea2
--- /dev/null
+++ b/gas.gif
Binary files differ