Let's try and define what a Workflow
is. It might be easier it we make this issues based on some Swift-pseudo code.
struct Workflow {
var name: String
var combinations: [Combination]
var commands: [Command]
}
.name: String
The idea with a workflow is that you can name them to describe what they are doing, mainly because they can contain a collection of commands. When it comes to UI, we could try and predict what kind of workflow name should be appropriate for the user.
So if a user adds a workflow with one application command, we could provide a default the suggestion that reads something like this:
Open "Finder" application
But if it contains multiple commands, it might be more appropriate to either suggest or at least give the user the opportunity to rename it. Here is an example for a workflow that open "office" applications.
Example command:
Workflow(commands: [
ApplicationCommand(bundleIdentifier: "com.apple.Mail"),
ApplicationCommand(bundleIdentifier: "com.apple.Calendar"),
ApplicationCommand(bundleIdentifier: "com.apple.Contacts")
])
Example name:
.combinations: [Combination]
The idea here is that you might want to bundle keyboard shortcuts invocations with the same "igniting"-key and have multiple other commands exposed when the first invocation has been fired.
Example commands that are scoped under the same combination
Workflow(
name: "Open Mail",
combinations: [
Combination(source: "ββ₯A"), Combination(source: "ββ₯M")
]
)
Workflow(
name: "Open Calendar",
combinations: [
Combination(source: "ββ₯A"), Combination(source: "ββ₯C")
]
)
So when ββ₯A
is invoked, we filter on the first combination and then move on to the next, that way we can bundle and funnel the invocation to the appropriate command at the end. Hope that makes sense.
Soβ¦
The keyboard shortcut: ββ₯A
followed by ββ₯M
would open Mail.
The keyboard shortcut: ββ₯A
followed by ββ₯C
would open Contacts.
It would mean that ββ₯A
is the "igniting"-key for both commands.
The motivation behind going in this direction is the amount of bindings that a user can create. It is kinda of similar with how emacs
bindings work.
.commands: [Command]
A collection of commands that will executed in linear order. For more information about commands, there is more in-depth details here #4
I have this idea of input
and output
for certain commands so that you can create a workflow that has chained commands.
Example:
- Run a shell script
- Pass the output and use it as input for the next command
- Perhaps announce the final result using a specialized
NotificationCommand
.
The chaining might come with some additional complexity, so Let's hold of from that idea for the time being but we should have it in the back of our heads that this is something that we might want to do in the future.