 	:group 'tools
 	:group 'convenience)
 
-(defcustom boop-success "1"
-	"The echo string to deem a plugin as successful"
-	:group 'boop
-	:type 'string)
+(defcustom boop-format-default '("?" "#ffcb13")
+  "The default config to propertize when a script echo result
+  doesn't matcha value in the `boop-monitor-alist`.")
 
-(defcustom boop-success-colour "#63ca13"
-	"The colour to use for success."
-	:group 'boop
-	:type 'string)
-
-(defcustom boop-failure "0"
-	"The echo string to deem a plugin as failed"
-	:group 'boop
-	:type 'string)
-
-(defcustom boop-failure-colour "#c64512"
-	"The colour to use for failure."
-	:group 'boop
-	:type 'string)
-
-(defcustom boop-warning-colour "#ffcb13"
-	"The colour to use for success."
-	:group 'boop
-	:type 'string)
-
-(defcustom boop-monitor-symbol "●"
-	"The symbol used as the monitor thing."
-	:group 'boop
-	:type 'string)
+(defcustom boop-format-alist
+  '(("1" "✓" "#63ca13")
+    ("0" "×" "#c64512"))
+   "An alist of values of the form (RESULT CHARACTER COLOUR) used
+   to map the echo results of the plugin scripts to characters
+   and their colours.")
 
 (defcustom boop-execution-strategy 'config
   "The startegy to use for executing plugins.

  (let ((plugins (boop--get-plugin-scripts)))
    (mapcar '(lambda (it) (cons (intern (file-name-base it)) it)) plugins)))

(defun boop-format-info ()
  "Format the info values"
  (mapconcat
   '(lambda (info)
      (cond ((string-equal (cdr info) boop-success) (boop--success (format "%s" (car info))))
            ((string-equal (cdr info) boop-failure) (boop--failure (format "%s" (car info))))
            (t (boop--warning (format "%s" (car info)))))) boop-info-alist ""))

(defun boop-sync-info-and-config ()
  "Synchronizes the info alist so that it only contains items in the config alist."
  (setq boop-info-alist (--filter (assoc (car it) boop-config-alist) boop-info-alist)))

(defun boop-handle-update-result (id result)
  "Handle the result of the async `shell-command-to-string`"
  (if (assoc id boop-info-alist)
      (setf (cdr (assoc id boop-info-alist)) result)
    (setq boop-info-alist (append (list (cons id result)) boop-info-alist))))

(defun boop-update-info ()
  "Execute all of the plugins and return a list of the results."
	(let* ((plugins (boop--get-plugin-alist)))
    (boop-sync-info-and-config)
	  (-map (lambda (config)
            (let* ((id (car config))
                   (script (cdr (assoc (cadr config) plugins)))
                   (args (mapconcat 'identity (cddr config) " "))
                   (cmd (format "%s %s" script args)))
              (async-start `(lambda () (shell-command-to-string ,cmd))
                           `(lambda (result) (boop-handle-update-result (quote ,id) (s-trim result))))))
          boop-config-alist)))

;; Interactive Functions

(setq boop-config-alist
      '((service-fuji jenkins "jenkins.connected-tv.tools.bbc.co.uk" "service-fuji")
        (contract-validation-int jenkins "jenkins.connected-tv.tools.bbc.co.uk" "taf-api-contract-validation-tests-on-int")
        (taf-router jenkins "jenkins.connected-tv.tools.bbc.co.uk" "taf-router")
        (script pass "??")))

(defvar boop-result-alist nil
	"This is an alist that is created based on the current
	`boop-config-alist` to keep the results synchronized when
	performing asynchronous actions")
