Swiftpack.co - Magic-Unique/AlfredKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Magic-Unique.
Magic-Unique/AlfredKit 2.0.2
Alfred workflow api
⭐️ 0
🕓 2 years ago
macOS
.package(url: "https://github.com/Magic-Unique/AlfredKit.git", from: "2.0.2")

AlfredKit

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

For Objective-C

AKScriptFilter *scriptFilter = [[AKScriptFilter alloc] init];
scriptFilter.useXMLMode = NO;
/*
 * Use XML mode, default is NO. 
 * XML mode is deprecated by Alfred.
 * If `useXMLMode` is NO, it will use JSON mode. 
 */

//    Add an item to list
[scriptFilter addItemWithCreator:^(AKItem *item) {
    // title
    item.title = @"title";
    item.subtitle = @"subtitle";

    //    auto complete with TAB key
    item.autocomplete = @"aktool";

    //    arg for next step
    item.arg = @"arg";

    //    icon, [FileType|FileIcon|Image]
    [item.icon setFileTypeWithPathExtension:@"app"];

    //    subtitle (only for XML mode)
    //    When user hold on the mod key, Alfred will display the first arg as subtitle
    [item setSubtitle:@"subtitle AKModKeyCommand" mod:AKModKeyCommand];
    [item setSubtitle:@"subtitle AKModKeyOption" mod:AKModKeyOption];
    [item setSubtitle:@"subtitle AKModKeyControl" mod:AKModKeyControl];
    [item setSubtitle:@"subtitle AKModKeyShift" mod:AKModKeyShift];
    [item setSubtitle:@"subtitle AKModKeyFn" mod:AKModKeyFn];

    //    Mod key (recommand, for XML and JSON)
    //    When user hold on the mod key, Alfred will display the subtitle.
    //    If user hold on the mod key and press RETURN, the arg will pass to next step.
    [item setMod:AKModKeyCommand subtitle:@"mod AKModKeyCommand" arg:@"AKModKeyCommand"];
    [item setMod:AKModKeyOption subtitle:@"mod AKModKeyOption" arg:@"AKModKeyOption"];
    [item setMod:AKModKeyControl subtitle:@"mod AKModKeyControl" arg:nil];
    [item setMod:AKModKeyShift subtitle:@"mod AKModKeyShift" arg:@"AKModKeyShift"];
    [item setMod:AKModKeyFn subtitle:@"mod AKModKeyFn" arg:@"AKModKeyFn"];

    //    When user press cmd+C, the text will be copied.
    [item setCopyText:@"onCopyText"];

    //    When user press cmd+L, the text will display on LargeType window.
    [item setLargeText:@"onLargeText"];

    //    When user press cmd+Y or Shift, the url or path will open in QuickLook window.
    item.quicklookurl = @"https://www.alfredapp.com";
}];

//  Add variables to list, on next step, you can use {var:name} query to get them.
scriptFilter.varables[@"name"] = @"value";

//    Set rerun time interval.
scriptFilter.rerun = 1;

//    Format string and output to Alfred console.
[scriptFilter show];

For Swift

import AlfredKit

var scriptFilter = ScriptFilter(format: .json)
scriptFilter.append {
    $0.title = "Title"
    $0.subtitle = "Subtitle"
    $0.icon = .type("png")
    $0.valid = false
    $0.arg = "Arguments"
    $0.on(press: .option, subtitle: "Press `option`")
    $0.quicklookurl = "https://www.baidu.com"
    $0.text.largetype = "text.largetype"
    $0.text.copy = "text.copy"
    $0.autocomplete = @"aktool";
}
scriptFilter.variables["aa"] = "bb"
scriptFilter.rerun = 1
scriptFilter.show(format: .json)

Installation

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

For Objective-C

pod 'AlfredKit'
# or
pod 'AlfredKit/ObjC'

For Swift

pod 'AlfredKit/Swift'
dependencies: [
    .package(url: "https://github.com/Magic-Unique/AlfredKit.git", from: "2.0.0")
],

Author

Magic-Unique, [email protected]

License

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

GitHub

link
Stars: 0
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics