Giter Club home page Giter Club logo

scpl's Introduction

Note that ScPL has not been updated to support the new iOS 13/14+ actions. If you are looking for a text shortcuts language, consider Jellycuts.

Project logo

ScPL

Build Status codecov discord


ScPL is a programming language for writing iOS Shortcuts in text.

ScPL is a programming language for Shortcuts that allows you to write shortcuts in text instead of dragging and dropping blocks. ScPL lets you work with large shortcuts easily by letting you copy and paste actions, view long shortcuts without scrolling, and type actions instead of dragging them in. Get Started

ShowResult "Hello ScPL"
ChooseFromMenu prompt="ScPL" items=["Getting Started", "View Documentation"]
Case "Getting Started"
    URL "https://docs.scpl.dev/gettingstarted"
Case "View Documentation"
    URL "https://docs.scpl.dev/"
End Menu
OpenURLs

See what your shortcut looks like in ScPL by uploading it in the ScPL Editor.

What is ScPL

ScPL lets you write shortcuts in text. Instead of dragging actions around on a small screen in a slow app, you can write text like ShowResult "My shortcut" to build long and complex shortcuts.

Editors

Web Editor

The ScPL Web Editor (editor.scpl.dev) is the easiest way to write ScPL.

Visual Studio Code

ScPL has a plugin for Visual Studio Code with autocompletion, error messages, and hover documentation. VSCode Extension.

To compile your ScPL code you can use the scpl-cli npm package. npm install --global scpl-cli. Then you can run scpl <filename.scpl> -o <outputfile.shortcut>

Usage (in other Javascript projects)

npm install --save scpl or yarn add scpl

const {parse, inverse} = require("scpl");
 
const {shortcutjson, shortcutplist} = parse("text 'hello scpl'", {make: ["shortcutjson", "shortcutplist"]});
// shortcutjson is a json object containing the shortcut file.
// shortcutplist is a buffer containing the shortcut file bplist.
 
const inverted = inverse(shortcutplist);
// text "hello scpl"

Contributing

Prerequisites

ScPL uses yarn for package management. Install Yarn

Installing

git clone https://github.com/pfgithub/scpl.git
cd scpl
yarn install

The ScPL repository does not have any tools for converting ScPL code to .shortcut files. That can be found in the scpl-editor or the scpl-cli projects.

Running tests

yarn test

ScPL tests using Jest and automatically generates coverage reports. You can use the coverage report lcov file in coverage/lcov.info to set your editor to show test coverage.

Before making a pull request

yarn prepublishOnly

prepublishOnly will automatically format your code using prettier and make sure tests pass.

Acknowledgements

  • xAlien95 for finding the actions plist file within the shortcuts ipa and manually making lists of all the variable types and aggrandizements.
  • Shortcuts JS for the complete shortcut glyph and color list.

scpl's People

Contributors

pfgithub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scpl's Issues

Apply callback functions to data after parsing

Have the parser return some kind of data which can be easily traversed and apply callback functions on it.

~134ms parse with callbacks, ~66ms without, given the number of unused parses it might actually make a performance difference. Most unused parses never callback though so who knows.

File Loader

For the @import action, generally this will happen

  • The main file will be parsed and cached
  • Using the caches, scripts will be parsed until an import action is called. If a cache exists for it, it will use the cache. (exits using throw probably, algebraic effects would be perfect for this but don't exist, a sync process otherwise needs to be frozen until an async finishes which is not possible in a browser, if using a warning it may take longer to do everything but then multiple files could be imported at once)
  • The fileLoader function will be called on the file to be imported
  • The loaded file will be parsed and cached
  • The process repeats until all files are imported and converting finishes sucessfully

FormatDate is broken

FormatDate's WFDateFormatStyle references an argument that isn't set yet in a relation resource...

Maybe do a manual override and detect and error on issues like these?

Add ??abc?? syntax

This syntax will be used in the inverse converter to signify that something went wrong. For better error messages, add support for it with a ErrorParse that throws this.error on all .as types

text ??huh there is an error??
getvariable s:??invalid variable??
text "My variable is: \(mv:??broken magic variable??)"

Per file tests

Jest supports having tests next to normal files as filename.spec.ts . This would be useful to have in addition to tests that make sure scpl code compiles and inverses as expected.

Shortcuts 3.0

Shortcuts 3.0 support will not be worked on until iOS allows shortcuts to be imported from .shortcut files. Until then, it is not known if it ever will and development cannot be tested.

Major Changes in Shortcuts 3.0:


Some actions, such as the CombineText action have been moved to separate files that includes all their information such as Name and Parameters (Presumably an intent declaration file but I haven't found it yet). Add support for loading action data from these files


Commonly used actions such as if now have their own custom parameter types and show different things based on the type of arguments passed into them. ScPL will now need to keep track of variable types at all times and use aggrandizements to make sure they always have as: set as ScPL assumes they do. (iOS might track variable as: differently). ScPL will also need significantly more information about types and have argument classes like for if with lots of different enum values based on other values.


Shortcuts now uses a natural language format for actions. ScPL could support this format. For example: Set variable (name) to (value). This might not be possible because of conflicts or might be a bad idea because you would constantly need to look up documentation.


Things that need to be changed in ScPL:


Change inputarg (^) to set the WFInput parameter instead of setting the action above.

For example:

in 2.2 that makes Text "hi" SetVariable v:myvar
in 3.0 it should make Text "hi" -> mv:var SetVariable input=mv:var value=v:myvar

Default actions that accept WFInput but don't have an inputarg parameter to use the action above them.

For example:

In 2.2, Text "hi"; SetVariable v works
In 3.0, it must be Text "hi" -> mv:var; SetVariable mv:var v

So, if an action does not have its WFInput defined, set it to the action above it.


Remove WFExpandingParameter, what's the point of it

If an action is not defined, put a placeholder error action in

something like undefinedaction, in shortcuts it would show as the action does not exist, in the wip web editor it would have a custom error render, cc could handle having multiple errors and this could allow having multiple errors.

Same thing for undefined magic variables and named variables, output an error and an invalid UUID to make it red.

Last action requires a newline after it

The last action requires a newline, causing strange things like @{Text "hi"} to error. This was worked around before @{} by adding a newline to the end of the file but it needs a real fix now

Use arrow syntax for actions too

For example,

Count Items -> (QuickLook)

|
v

Count Items -> mv:Items
QuickLook
GetVariable mv:Items

maybe, not sure about this one.

variables have asnametype and actions have asaction so check if asnametype (do variable things) else (at end, varflag.asAction(), action.variable)

Separate CLI into its own package

Both yargs and chalk are only used for the CLI, but in some cases I am only using the Node.js API. Personally, I think it would be better to split this into a scpl-cli package and link between the two.

Variable aggrandizements

ScPL only supports get:, as:, and key: right now. More such as those in the Date coercion type could be helpful.

Variables require types when using as:

Actions have some data to say what their output type is. If cc keeps track of this, ScPL could guess what type a variable is and set it when using as:

Allow multiple error messages

For example, an error like variable does not exist could be shown in combination with other errors.

Also, allow some errors to generate output anyway. For example, magic variable does not exist could generate output with a broken magic variable (random unused uuid)

Refactor code

  • Remove build from the git repo (Done in a6f037b)
  • Parameters go in separate files (Done in da85d1c)
  • Move addStaticEnums to OutActions generation
  • Do something about WFAction
  • Rename OutputData
  • Move OutputData classes to their own files
  • Rename ParserData and find a more descriptive word for *Parse
  • Separate all *parses into their own separate files
  • Make all files with real code have less than 100 lines (excluding data files like GetTypes)

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.