This CLI can be used to control your Spotify account. It is meant as an example project to show how to build a command line interface in a language that runs on the JVM.
Download a binary from the releases page, and put the binary in your $PATH
.
This CLI supports autocomplete for various shells (bash
, zsh
, fish
). To enable autocomplete, source the completion script upon starting a shell (through your profile, or rc
file):
source <(spot --generate-completion bash)
Replace bash
with the shell of your choice.
In order to compile the source to a valid binary (that can be run standalone), make sure that you have the following installed:
- GraalVM 20.3.0.r11 (or greater; should also work)
- Native Image GraalVM component (
gu install native-image
)
Make sure when running maven, you've set GraalVM as the JDK to use in that shell (hence, JAVA_HOME
is set to GraalVM).
Tip: use direnv
, and create an .envrc
file in the root of this repository, with the following contents:
export JAVA_HOME=path/to/graalvm/java_home
export PATH=$JAVA_HOME/bin:$PATH
This automatically activates and sets GraalVM as the active JDK.
To successfully use the CLI, make sure to create application.conf
in src/main/resources
, with the following contents:
cli {
clientId = "<the client id for your Spotify app>"
clientSecret = "<the client secret for your Spotify app>"
}
To create a clientId
and clientSecret
, go to the Spotify Developer dashboard.
Feel free to use, copy, and modify this code to fit your needs. A reference towards this repository is appreciated :)
The requested scopes for this app are far too much, don't do this in real life ;)
Multi platform builds inspired by this blog post.