diff --git a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java index 5b0e3ae..8a751a2 100644 --- a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java +++ b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/LastFMToSpotify.java @@ -47,10 +47,6 @@ public class LastFMToSpotify { } } - logLn("Priority 0",0 ); - logLn("Priority 1",1 ); - logLn("Priority 2",2 ); - logLn("Priority 3",3 ); // Start Progress Bar try (ProgressBar pb = new ProgressBar("LastFM -> Spotify Playlist", 4)) { @@ -64,7 +60,7 @@ public class LastFMToSpotify { case 2: pb.setExtraMessage("Authenticating with LastFM..."); Caller.getInstance().setUserAgent(configuration.get("requests.useragent")); - User.getInfo(configuration.get("lastfm.user"), configuration.get("lastfm.apikey")).getName(); + logLn(User.getInfo(configuration.get("lastfm.user"), configuration.get("lastfm.apikey")).getName(), 1); break; case 3: pb.setExtraMessage("Reading from LastFM..."); diff --git a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/ArgumentHandler.java b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/ArgumentHandler.java index e2b572d..400a643 100644 --- a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/ArgumentHandler.java +++ b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/ArgumentHandler.java @@ -1,6 +1,5 @@ package de.b00tload.tools.lastfmtospotifyplaylist.arguments; -import de.b00tload.tools.lastfmtospotifyplaylist.util.Logger; import org.jetbrains.annotations.Nullable; import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.LINE_SEPERATOR; @@ -12,6 +11,10 @@ public class ArgumentHandler { switch (argument){ case HELP -> help(value); case VERBOSE -> verbose(value); + case SECRET -> secret(value); + case CLIENT -> client(value); + case TOKEN -> token(value); + case USER -> user(value); } } @@ -53,6 +56,10 @@ public class ArgumentHandler { } private static void verbose(String value){ + if(value == null){ + System.out.println("--loglevel must be provided with a numeric log level. Check usage: " + Arguments.VERBOSE.getUsage()); + System.exit(500); + } try { int loglevel = Integer.parseInt(value); configuration.put("logging.level", String.valueOf(loglevel)); @@ -62,4 +69,36 @@ public class ArgumentHandler { } } + + private static void token(String value) { + if(value == null || value.equalsIgnoreCase("")){ + System.out.println("--lastfmtoken must be provided with an api token from LastFM. Check usage: " + Arguments.TOKEN.getUsage()); + System.exit(500); + } + configuration.put("lastfm.apikey", value); + } + + private static void user(String value) { + if(value == null || value.equalsIgnoreCase("")){ + System.out.println("--lastfmuser must be provided with a LastFM username. Check usage: " + Arguments.USER.getUsage()); + System.exit(500); + } + configuration.put("lastfm.user", value); + } + + private static void client(String value) { + if(value == null || value.equalsIgnoreCase("")){ + System.out.println("--spotifyclient must be provided with a client id from Spotify. Check usage: " + Arguments.CLIENT.getUsage()); + System.exit(500); + } + configuration.put("spotify.clientid", value); + } + + private static void secret(String value) { + if(value == null || value.equalsIgnoreCase("")){ + System.out.println("--spotifysecret must be provided with a client secret from Spotify. Check usage: " + Arguments.SECRET.getUsage()); + System.exit(500); + } + configuration.put("spotify.secret", value); + } } diff --git a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/Arguments.java b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/Arguments.java index f535f66..e509f79 100644 --- a/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/Arguments.java +++ b/src/main/java/de/b00tload/tools/lastfmtospotifyplaylist/arguments/Arguments.java @@ -16,7 +16,14 @@ public enum Arguments { + " - 2: Verbose Will echo current step being worked on" + LINE_SEPERATOR + " - 3: Debug Will give specific information on what excactly the tool is doing", "--loglevel ", "log", "l"), - SECRET("spotifysecret", "[]", "--spotifysecret ", "sS", "sSecret"); + SECRET("spotifysecret", "[Required]" + LINE_SEPERATOR + + "Sets the spotify client secret.", "--spotifysecret ", "sS", "sSecret"), + CLIENT("spotifyclient", "[Required]" + LINE_SEPERATOR + + "Sets the spotify cliend id.", "--spotifyclient ", "sC", "sClient"), + TOKEN("lastfmtoken", "[Required]" + LINE_SEPERATOR + + "Sets the LastFM API token.", "--lastfmtoken ", "lT", "lToken"), + USER("lastfmuser", "[Required]" + LINE_SEPERATOR + + "Sets the LastFM API token.", "--lastfmuser ", "lU", "lUser"); private final String name; private final String description;