 ]
 
 
-class ProjectConfiguration
+class Project
   constructor: () ->
     @directory = ''
     @images = []

# @param [Object] args the arguments to the program
#
remove = (args) ->
  id = args[3]
  images = config.images
  filteredImages = images.filter (obj) -> obj.id != args[3]
  if images.length == filteredImages.length
    log.warning "Couldn't uninstall image with ID '#{id}' because it's not" \
      + ' installed in the first place.'
  else
    config.images = filteredImages
    persistProject()


# Attempts to load the user and dependency configuration files.
#
loadConfig = () ->
  if existsFile.sync USER_PATH
    user = jsonfile.readFileSync USER_PATH
  else
    log.error "Couldn't find your '#{USER_PATH}' file to get your API key." \
      + ' You should probably run \'picksel auth\' to set one up.'
    return false
  if existsFile.sync CONFIG_PATH
    config = jsonfile.readFileSync CONFIG_PATH
  else
    log.error "Couldn't find your '#{CONFIG_PATH}' file with all your" \
      + ' dependencies. You should probably run \'picksel init\' to set one' \
      + ' up.'
    return false
  true


# Prompts the user to create a directory if it doesn't exist yet.

#
# @param [Object] image the image to grab
grab = (image) ->
  path = "./#{project.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 project.
#
install = () -> grab image for image in project.images


# Checks whether or not a string contains only numeric characters.
#
# @param [String] str the string to test
#
isNumeric = (str) -> /^\d+$/.test str


# Validates that an ID maps to an image on Pixabay.
#
# @param [String] id the ID to check
#
validateId = (id, callback) ->
  url = buildUrl user.apiKey, id, (if isNumeric then 0 else 2) # Hash ID?
  options =
    url: url
    json: true
  request url, (error, response, body) -> # Request image JSON.
    callback(!error && response.statusCode == 200)


# Adds an image as an asset.
