Giter Club home page Giter Club logo

python-shortcuts's Introduction

WIP: python-shortcuts

Build Status PyPI

๐Ÿ + ๐Ÿ = โค๏ธ

python-shortcuts is a library to create Siri Shortcuts on your laptop with your favourite text editor. It uses toml to represent shortcuts.

The library is in a very early development state (PR welcome!), so it does not support all actions from Shortcuts app.

Supported Python version: >=3.6.

Why

I wanted to convert my shortcut to a file in human-readable format. :)

From the code below this library can create a working shortcut:

[[action]]
type = "ask"
question = "What is your name?"

[[action]]
type = "set_variable"
name = "name"

[[action]]
type = "show_result"
text = "Hello, {{name}}!"

Or the same with Python:

from shortcuts import Shortcut, actions


sc = Shortcut()

sc.actions = [
    actions.AskAction(data={'question': 'What is your name?'}),
    actions.SetVariableAction(data={'name': 'name'}),
    actions.ShowResultAction(data={'text': 'Hello, {{name}}!'})
]

How to use

Installation

pip install shortcuts

Usage

shortcut โ†’ toml

If you need to convert existing shortcut to a toml file, at first you need to export it. Go into Shortcuts app, open the shortcut and share it. Choose "Share as file" and use this file with this library.

Convert shortcut file to toml:

shortcuts what_is_your_name.shortcut what_is_your_name.toml

toml โ†’ shortcut

Convert a toml file to a shortcut file. After you will need to open the file with iOS Shortcuts app.

shortcuts examples/what_is_your_name.toml what_is_your_name.shortcut

More examples of toml files you can find here. And read the tutorial! :)

URL โ†’ [toml|shortcut]

Also, you can download shortcut directly from iCloud. If somebody shared shortcut link with you, just run:

shortcuts https://www.icloud.com/shortcuts/... my_shortcut.toml  # or my_shortcut.shortcut

And it will download this shortcut and save it in toml or shortcut format.

Docker

It's possible to use pre-built Docker container with python-shortcuts inside:

# convert s.toml from the current directory into s.shortcut

docker run -v $(pwd):/files akhmetov/shortcuts-cli /files/s.toml /files/s.shortcut


docker run -v $(pwd):/files akhmetov/shortcuts-cli --help

    usage: shortcuts [-h] [--version] [file] [output]

    Shortcuts: Siri shortcuts creator

    positional arguments:
      file        Input file: *.(toml|shortcut|itunes url)
      output      Output file: *.(toml|shortcut)

    optional arguments:
      -h, --help  show this help message and exit
      --version   Version information

Development

Tests

Run tests:

tox

How to add a new action

See documentation.

TODO

  • โ˜‘ Conditionals with auto-group_id: if-else, menu
  • โ˜ Nested fields: dict/array/etc
  • โ˜ Support variables in every field which support them in Shortcuts app
  • โ˜ Workflow types: widget, etc.
  • โ˜ Import questions
  • โ˜ Document all actions
  • โ˜ Support magic variables
  • โ˜ Support all current actions from Shortcuts app

Similar projects

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.