{"id":13569773,"url":"https://github.com/RobTrew/prelude-applescript","last_synced_at":"2025-04-04T06:31:16.069Z","repository":{"id":40630140,"uuid":"138222845","full_name":"RobTrew/prelude-applescript","owner":"RobTrew","description":"Generic functions for macOS scripting with Applescript – function names as in Hoogle","archived":false,"fork":false,"pushed_at":"2024-06-13T12:12:42.000Z","size":2270,"stargazers_count":32,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-05T02:35:47.411Z","etag":null,"topics":["applescript","javascript","macos","prelude-based"],"latest_commit_sha":null,"homepage":null,"language":"AppleScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobTrew.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-21T21:18:53.000Z","updated_at":"2024-08-01T01:16:22.000Z","dependencies_parsed_at":"2024-01-14T03:47:28.951Z","dependency_job_id":"765181b6-8906-4226-beb8-5a5867945660","html_url":"https://github.com/RobTrew/prelude-applescript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTrew%2Fprelude-applescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTrew%2Fprelude-applescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTrew%2Fprelude-applescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTrew%2Fprelude-applescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobTrew","download_url":"https://codeload.github.com/RobTrew/prelude-applescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247134406,"owners_count":20889396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["applescript","javascript","macos","prelude-based"],"created_at":"2024-08-01T14:00:44.144Z","updated_at":"2025-04-04T06:31:13.440Z","avatar_url":"https://github.com/RobTrew.png","language":"AppleScript","funding_links":[],"categories":["AppleScript"],"sub_categories":[],"readme":"# prelude-applescript\nGeneric functions for macOS scripting with Applescript – function names as in [Hoogle](https://www.haskell.org/hoogle/?hoogle=concatMap).\n\nIn Applescript it may be simpler to paste functions from this library\ninto your scripts, and use them directly, rather than referencing a\nglobal 'include' of the whole library.\n\nNevertheless, for initial drafting and testing, it is certainly possible\nto make the whole library (over 400 functions) available to a script:\n\n## Example\n\nHere is a script which shows a menu of all the functions\nin the library, inviting the user to choose one or more for pasting.\n\n(The source code of all selected functions is then copied to the clipboard):\n\n![Choosing functions to paste](./functionChoiceMenu.png)\n\n```applescript\nuse AppleScript version \"2.4\"\nuse framework \"Foundation\"\nuse scripting additions\n\n--     Rob Trew (c) 2018 MIT\n\n--     macOS menu for choosing a set of Applescript Prelude functions to paste.\n\nproperty _ : missing value\n\n--  EDIT THESE FILEPATHS TO MATCH YOUR SYSTEM:\n\n-- Library files at: https://github.com/RobTrew/prelude-applescript\nproperty jsonPath : \"~/prelude-applescript/asPreludeDict.json\"\nproperty asPreludeLibPath : \"~/prelude-applescript/asPrelude.applescript\"\n\non run\n    if _ is missing value then set _ to prelude(asPreludeLibPath)\n\n    script functionMenu\n        on |λ|(recFns)\n            tell _ to set ks to sort(keys(recFns))\n            tell application \"System Events\"\n                activate\n                set choice to choose from list ks ¬\n                    with title \"Applescript Prelude\" with prompt \"( \" \u0026 ¬\n                    (length of ks) \u0026 \" functions )\" \u0026 ¬\n                    linefeed \u0026 linefeed \u0026 ¬\n                    \"Choose one or more to paste:\" default items {item 1 of ks} ¬\n                    with multiple selections allowed\n\n                if choice is not false then\n                    script sourceCode\n                        on |λ|(k)\n                            set mbSource to _'s lookupDict(k, recFns)\n                            if Nothing of mbSource then\n                                {}\n                            else\n                                {Just of mbSource}\n                            end if\n                        end |λ|\n                    end script\n                    tell _ to set strFns to intercalate(linefeed \u0026 linefeed, ¬\n                        concatMap(sourceCode, choice))\n\n                    -- VALUE RETURNED\n                    set the clipboard to strFns\n                    strFns\n                else\n                    \"\"\n                end if\n            end tell\n        end |λ|\n    end script\n\n    tell _\n        if doesFileExist(jsonPath) then\n            set lrJSON to readFileLR(jsonPath)\n        else\n            set lrJSON to |Left|(\"File not found: \" \u0026 jsonPath)\n        end if\n\n        bindLR(bindLR(lrJSON, _'s jsonParseLR), functionMenu)\n    end tell\nend run\n\n-- prelude :: FilePath -\u003e Script\non prelude(filePath)\n    -- (path to a library file which returns a 'me' value)\n\n    set ca to current application\n    set {bln, int} to (ca's NSFileManager's defaultManager's ¬\n        fileExistsAtPath:((ca's NSString's stringWithString:filePath)'s ¬\n            stringByStandardizingPath) isDirectory:(reference))\n\n    if (bln and (int ≠ 1)) then\n        set strPath to filePath\n        run script (((ca's NSString's ¬\n            stringWithString:strPath)'s ¬\n            stringByStandardizingPath) as string)\n    end if\nend prelude\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobTrew%2Fprelude-applescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRobTrew%2Fprelude-applescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobTrew%2Fprelude-applescript/lists"}