Discogs.CLI (discogs_shuffle v0.2.0) View Source

Entry-point for the CLI app.

This is used as escript's :main_module.

cf. https://elixirschool.com/en/lessons/advanced/escripts/

Link to this section Summary

Functions

Parses the ARGV and either syncs or shuffles a user's collection, depending on the arguments given.

Shuffles records a user's collection, returning n = num_records.

Fetches a user's collection from Discogs, persists all associated models to the local db and updates the user's collection if had been stored previously.

Link to this section Functions

Specs

main([String]) :: :ok

Parses the ARGV and either syncs or shuffles a user's collection, depending on the arguments given.

Options include:

--sync USER -> sync_collection/1

--shuffle USER <N> -> shuffle_collection/2

Invalid or no arguments defer to the usage doc.

Link to this function

shuffle_collection(username, num_records)

View Source

Specs

shuffle_collection(username :: String.t(), num_records :: pos_integer()) :: [
  %Discogs.Models.Record{
    __meta__: term(),
    artists: term(),
    disc_number: term(),
    id: term(),
    inserted_at: term(),
    release: term(),
    release_id: term(),
    updated_at: term()
  }
]

Shuffles records a user's collection, returning n = num_records.

Link to this function

sync_collection(username)

View Source

Specs

sync_collection(username :: String.t()) :: :ok

Fetches a user's collection from Discogs, persists all associated models to the local db and updates the user's collection if had been stored previously.