PureScript library for interfacing with the APIs exposed by the Scriptable iOS app.
This example script takes textual action extension input and counts either the Characters, the Words, or the number of Lines in the supplied text.
data Option = Characters | Words | Lines
instance showOption :: Show Option where
show Characters = "Characters"
show Words = "Words"
show Lines = "Lines"
optionToSplitPattern :: Option -> Pattern
optionToSplitPattern Characters = Pattern ""
optionToSplitPattern Words = Pattern " "
optionToSplitPattern Lines = Pattern "\n"
showOptionAlert :: Aff (AlertResult Option)
showOptionAlert = newAlert # setTitle "Count what?"
>>> addActions ((Button Lines):(Button Words):(Button Characters):Nil)
>>> presentAlert
main :: Effect Unit
main = run $ do
Result (Button option) _ <- showOptionAlert
ArgsText text <- askIfNothing "No text passed from share sheet. Paste here instead." $ head argsText
let pattern = optionToSplitPattern option
split pattern text # length >>> show >>> displayString
- Checkout this repo in some directory, REPO, and then navigate to the desired project directory.
- Create a PureScript project with
pulp init
. - Install purescript-purely-scriptable
- Add the following as a dependency in bower.json
"purescript-purely-scriptable": "git://github.com/rlamacraft/purescript-purely-scriptable#v0.1.2"
- Run
bower update
andpulp build
to make sure everything works
- Add the following as a dependency in bower.json
- Write the Hello World program to src/Main.purs
module Main where import Prelude import Effect (Effect) import PurelyScriptable (run) import PurelyScriptable.Alert (displayString) main :: Effect Unit main = run $ do displayString "Hello, World!"
- Compile
- First run
pulp build
to check for anything obvious - When happy, build and deploy to iOS with the following
This will copy the compiled JavaScript file to
. $REPO/scripts/build.sh helloWorld
~/Library/Mobile\ Documents/iCloud~dk~simonbs~Scriptable/Documents/
, the default location of the Scriptable iCloud directory.
- First run
- Wait for iCloud to sync, and then execute from the Scriptable iOS app.