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

# Walks the user through initializing their project file.
#
init = () ->
  existsFile CONFIG_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 ProjectConfiguration() # 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 '#{CONFIG_PATH}' for holding" \
                  + ' your asset dependencies. Feel free to check this file' \
                  + ' in to source control.' # Project setup success!


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

readline = require 'readline'

