Giter Site home page Giter Site logo

discontinuity-srl / dsunixtask Goto Github PK

View Code? Open in Web Editor NEW
40.0 5.0 2.0 156 KB

DSUnixTask is a library for Mac OS X which allows to launch and interact with awesome looking UNIX tasks.

License: MIT License

C 12.41% Objective-C 67.17% MATLAB 17.65% Ruby 2.77%

dsunixtask's Introduction

DSUnixTask

DSUnixTask is a library for Mac OS X which allows to launch and interact with awesome looking UNIX tasks.

Features:

  • Simple interface based on blocks.
  • Process standard output and standard error in real-time.
  • Easily send messages to standard input.
  • Execute tasks either as sub-processes or through an XPC service.
  • Execute throughout the user shell.
  • Logging.

Running a task as a sub-processes

Podfile:
pod 'DSUnixTask/Core'
Usage:
#import <DSUnixTaskSubProcessManager.h>

- (void)runTasfk {
  [[DSUnixTaskSubProcessManager sharedManager] setLoggingEnabled:TRUE];
  DSUnixTask *task = [DSUnixTaskSubProcessManager shellTask];
  [task setCommand:@"/bin/cat"];
  [task setStandardOutputHandler:^(DSUnixTask *task, NSString *output) {
    NSLog(@"%@", output);
  }];
  [task launch];
  [task writeStringToStandardInput:@"Hi!"];
}

XPC

XPC Service:

To create the target for the XPC service:

  1. Use the XPC Service template.
  2. Add a Copy Files build phase to the application.
  • Destination: Wrapper.
  • SubPath: Contents/XPCServices.
  • Copy the XPC service product
  1. Add a dependency to your application’s build phases on the XPC Service.
Podfile:
target 'MyApp' do
  pod 'DSUnixTask/XPCClient'
end

target 'XPCservice' do
  pod 'DSUnixTask/XPCService'
end
Usage:
Client:
#import <DSUnixTaskXPCManager.h>

- (void)runTask {
  [[DSUnixTaskXPCManager sharedManager] setServiceBundleIdentifier:@"com.compary.xpc-bundle-name"];
  [[DSUnixTaskXPCManager sharedManager] setLoggingEnabled:TRUE];
  DSUnixTask *task = [DSUnixTaskSubProcessManager shellTask];
  [task setCommand:@"/bin/cat"];
  [task setStandardOutputHandler:^(DSUnixTask *task, NSString *output) {
    NSLog(@"%@", output);
  }];
  [task launch];
  [task writeStringToStandardInput:@"Hi!"];
}
Service:
#include <Foundation/Foundation.h>
#import "DSUnixTaskServiceMain.h"

int main(int argc, const char *argv[]) {
  runUnixTaskXPCService();
}

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.