   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."

#
# @param [Object] image the image to grab
grab = (image) ->
  path = "./#{config.directory}/#{image.destination}"
  log.info "Installing image with ID #{image.id} at resolution" \
    + "#{humanResolutions[image.resolution]} to #{path}"
  download image.id, image.resolution, path


# Installs all images present in the currently loaded configuration.
#
install = () -> grab image for image in config.images


# Adds an image as an asset.

# Walks the user through initializing their project file.
#
init = () ->
  existsFile PROJECT_PATH, (err, stats) -> # Check for an existing project file.
    if stats
      log.warning 'Looks like this project has already been initialized for' \
        + ' Picksel.' # If file exists, inform user and abort.
    else
      log.info 'Let\'s initialize Picksel for this project...'
      newProj = new Project() # Initialize new project.
      ask 'Relative to the current directory, where would you like to store' \
        + ' assets? ', (answer) ->
          promptDirectoryCreation answer, (err, exists) ->
            if !exists # Warn user about missing assets directory.
              log.warning "The #{answer} directory isn't present on disk. You" \
                + ' won\'t be able to install assets until it is.'
            newProj.directory = answer # Add asset path to project.
            persistProject newProj, (err) -> # Persist new project file.
              if err
                log.error 'Error writing your project file to disk!'
              else
                log.info "New file created at '#{PROJECT_PATH}' for holding" \
                  + ' your asset dependencies. Feel free to check this file' \
                  + ' in to source control.' # Project setup success!

