Giter Site home page Giter Site logo

iconifyit / jsx-oas-commander Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 768 KB

An AppleScript proxy to allow ExtendScript to run shell scripts and retrieve the results.

License: MIT License

Shell 15.37% AppleScript 84.63%
applescript extendscript jsx adobe illustrator

jsx-oas-commander's Introduction

JSX-OAS Commander

NB: This is a work-in-progress and not production-ready.

Description

An AppleScript proxy to allow ExtendScript to run shell scripts and retrieve the results in JSON format.

JavaScript Extension in Adobe Illustrator can call File().execute() but if you try to run this on a shell script, it will open the script in the Terminal app but does not run or return the results. The approach in this utility allows JSX to call File().execute() on the Commander.app applet and retrive the results.

The idea is to create an applet that will take any commands and parameters, execute them on the shell, including bash and NodeJS, and return the results in JSON format via a known output file.

System Requirements

Sorry, but this script works on MacOS only.

Installation

Download this repository to your Mac computer.

Usage

The basic workflow of this script is:

  1. From your JSX script, write the shell script you want to execute to path/to/jsx-oas-commander/input/command.sh
  2. From your JSX script, call new File("path/to/jsx-oas-commander/Commander.app").execute()
  3. Commander.app will read the input/command.sh text file and execute the enclose text as a shell script.
  4. The result of the shell script will be written to jsx-oas-commander/output/output.json.
  5. From your JSX script, read the results in jsx-oas-commander/output/output.json. The result will be in {result:"the restult text"}.
{
    "result": "scott"
}

Error Handling

If the script encounters an error, the JSON result will contain a null value for the result JSON property, and the addition of errnum and errmsg values. The errnum value is enclosed in quotes in case, for some reason, an empty value is returned. We do not enclose the null values for result in quotes since it is being hard-coded as a string literal so we are certain it is syntactically correct.

{
    "result": null, 
    "errnum": "-128", 
    "errmsg": "Something went terribly wrong."
}

jsx-oas-commander's People

Contributors

iconifyit avatar

Stargazers

 avatar  avatar Miquel Brazil avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.