Skip to content

Lemonbrush/DeepShell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepShell

DeepShell is a lightweight Swift framework for URL-based command routing and command execution

It allows you to define commands via a property list (plist) and execute them dynamically, supporting parameterized routes and wildcards

Quick Start

  1. Define commands in a plist (Commands.plist in your app bundle):
<plist version="1.0">
<dict>
  <key>CommandList</key>
  <array>
    <dict>
      <key>Alias</key>
      <array><string>myapp://search</string></array>
      <key>Class</key>
      <string>SearchCommand</string>
      <key>NeedLogin</key>
      <false/>
    </dict>
    <dict>
      <key>Alias</key>
      <array><string>myapp://user/$(userId)/profile</string></array>
      <key>Class</key>
      <string>UserProfileCommand</string>
      <key>NeedLogin</key>
      <true/>
    </dict>
  </array>
</dict>
</plist>
  1. Create commands conforming to DSCommand (UIViewController or service):
class SearchCommand: NSObject, DSCommand {
    var resultBlock: ((Error?, Any?) -> Void)?
    required override init() {}
    func run(params: [String: String]) {
        // perform search
        resultBlock?(nil, "results")
    }
}
  1. Initialize and setup DeepShell (e.g. in AppDelegate):
let shell = DeepShell()
shell.setupDeepShell(plistNames: ["Commands"])
  1. Execute a command:
shell.execute(urlString: "myapp://search?q=swift") { error, result in
    // handle result
}

About

Lightweight Swift framework for URL-based command routing and command execution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages