Skip to content

Commit

Permalink
Add command to start an application
Browse files Browse the repository at this point in the history
  • Loading branch information
norm committed Sep 12, 2021
1 parent 5d2ab78 commit 084497e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions documentation/kitfile.markdown
Expand Up @@ -116,3 +116,8 @@ Available commands are:
* symlink _SOURCE_ _DESTINATION_

Creates a symbolic link at _DESTINATION_ that points to _SOURCE_.

* start _APPLICATION_

Starts _APPLICATION_ in the background to stop it from stealing focus
while `kitout` is still running.
5 changes: 5 additions & 0 deletions kitout.sh
Expand Up @@ -134,6 +134,7 @@ function process_kitfile {
brewfile) brewfile "$argument" ;;
install) install_file $argument ;;
symlink) symlink $argument ;;
start) start "$argument" ;;
remind) remind "$argument" ;;

cron_entry) add_to_crontab "$argument" ;;
Expand Down Expand Up @@ -269,6 +270,10 @@ function symlink {
fi
}

function start {
open -g -a "$1"
}

function add_to_crontab {
local line="$*"
local tab="$(mktemp '/tmp/kitout.crontab.XXXXX')"
Expand Down
23 changes: 23 additions & 0 deletions tests/start.bats
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

@test cron_entry {
! contacts_is_running

run ./kitout.sh tests/start.kitfile

[ $status -eq 0 ]
contacts_is_running
}

function contacts_is_running {
ps x | grep '[/]Contacts.app/'
}

function setup_file {
teardown
}

function teardown {
pid=$(contacts_is_running | cut -d' ' -f1 )
[ -n "$pid" ] && kill $pid || true
}
1 change: 1 addition & 0 deletions tests/start.kitfile
@@ -0,0 +1 @@
start Contacts

0 comments on commit 084497e

Please sign in to comment.