   when 'init' then init()
   when 'auth' then auth()
   else
-    if loadConfig()
-      switch process.argv[2]
-        when 'install' then install()
-        when 'add' then add process.argv
-        when 'remove' then remove process.argv
+    loadWorkspace (success) ->
+      if success
+        switch process.argv[2]
+          when 'install' then install()
+          when 'add' then add process.argv
+          when 'remove' then remove process.argv
+      else
+        log.error "Couldn't load workspace for above reason. Terminating."

i18n = require 'i18n'
#pixabay = require 'pixabayjs'
yn = require 'yn'
mkdirp = require 'mkdir-p'

readline = require 'readline'


# @param [Object] args the arguments to the program
#
add = (args) ->
  id = args[3] # ID should be fourth argument.
  resolution = args[4] # Resolution code should be fifth argument.
  destination = args[5] # File destination should be sixth argument.
  if typeof id == 'undefined' \
    || typeof resolution == 'undefined' \
    || typeof destination == 'undefined'
      log.error 'You didn\'t provide enough arguments! Like this:' \
        + ' \'picksel add <id> <resolution> <destination>\'' # ID not passed in.
  else
    if isValidResolution resolution
      validateId id, (success) ->
        if success
          image =
            id: id
            resolution: resolution
            destination: destination
          project.images.push image # Add new image to project file.
          persistProject null, (err) -> # Update project file.
            if err
              log.error 'Error writing your project file to disk!'
            else
              log.info "Added image with ID '#{image.id}' as asset." # Success!
        else
          log.error "That ID #{id} isn't valid." # Invalid ID
    else
      log.error "That resolution '#{resolution}' isn't valid." # Bad resolution.


# Removes an image from installed assets.
