Giter Site home page Giter Site logo

scriptable's Introduction

Scriptable

CI Status Version License Platform

Scriptable will allow you to run and automate your daily basis Terminal tasks through a macOS app.

Scriptable protocol

public protocol Scriptable {
    
    typealias ScriptResponce = (command: String, errorOutput: String?, dataOutput: String)
    
    /// The command you want to execute through your terminal
    ///
    /// Keep in mind if you pass any aurgument with a space like:
    /// `open -a Some Application`
    /// you will need to remove the spaces between the app name "Some Application"
    var command: String { get }
    
    /// Run the task throue the terminal
    ///
    /// - Returns: The output string for (command: String, errorOutput: String?, dataOutput: String)
    @discardableResult func runTask(launchPath: String) -> ScriptResponce
}

Simple Example

enum MySimpleCommands: Scriptable {
    
    case openDesktop
    
    var command: String {
        switch self {
        case .openDesktop:
            return "cd ~ && cd Desktop/ && open ."
        }
    }
}

class ViewController: NSViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        MySimpleCommands.openDesktop.runTask() // This will open your desktop folder
    }
}

Scriptable Task

Scriptable provide a bunch of ready made tasks like: Network tasks, App tasks, Directory tasks and also you can run your random task through Custom task

Here is an example on how to get it:

Make sure you import Scriptable

import Scriptable

And inside any method you can say:

Task.Network.getSecureWebProxyInfo.runTask()

Note that runTask() marked as @discardableResult so it's actually returns some values like:

  • command: String
  • errorOutput: String?
  • dataOutput: String

You also can get access to those values to display them if you want to build a small Terminal app or for debugging purpose:

Task.Network.getSecureWebProxyInfo.runTask().dataOutput

Example

There is an example project thats allows you to turn on/off the proxy, simpl clone the repo, and run pod install from the Example directory first.

Requirements

Make sure to disable App Sandbox in your Cocoa Application (found under your Project app target > Capabilities tab > App Sandbox switch). If you didn't disable it you'll find that you're being blocked by a sandbox exception.

Installation

Scriptable is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Scriptable'

Author

cs4alhaider, [email protected]

License

Scriptable is available under the MIT license. See the LICENSE file for more info.

scriptable's People

Contributors

cs4alhaider avatar

Watchers

James Cloos 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.