diff --git a/Api/Api.csproj b/Api/Api.csproj
index 88cef6e..c5a3197 100644
--- a/Api/Api.csproj
+++ b/Api/Api.csproj
@@ -12,6 +12,7 @@
+
diff --git a/Api/Program.cs b/Api/Program.cs
index c3e22b6..a0e1c86 100644
--- a/Api/Program.cs
+++ b/Api/Program.cs
@@ -1,4 +1,5 @@
-using Microsoft.Extensions.Logging.Abstractions;
+using System.CommandLine;
+using Microsoft.Extensions.Logging.Abstractions;
namespace Api;
@@ -6,9 +7,32 @@ public class Program
{
public static async Task Main(string[] args)
{
- var username = Environment.GetEnvironmentVariable("BANDCAMP_USERNAME");
- var password = Environment.GetEnvironmentVariable("BANDCAMP_PASSWORD");
+ var username = CreateOption("--username", "Your Bandcamp account username.");
+ var password = CreateOption("--password", "Your Bandcamp account password.");
+ var album = CreateOption("--album", "ID of the album you want to download.");
+ var listCommand = new RootCommand("List all albums in your Bandcamp collection.")
+ {
+ username,
+ password,
+ };
+
+ var downloadCommand = new Command("download", "Download the album with the specified ID.")
+ {
+ username,
+ password,
+ album
+ };
+
+ listCommand.AddCommand(downloadCommand);
+ listCommand.SetHandler(List, username, password);
+ downloadCommand.SetHandler(Download, username, password, album);
+
+ await listCommand.InvokeAsync(args);
+ }
+
+ private static async Task List(string username, string password)
+ {
using var client = new Client(username, password, NullLoggerFactory.Instance);
await foreach (var item in client.GetCollection())
@@ -20,4 +44,17 @@ public static async Task Main(string[] args)
Console.WriteLine($"{id,10} {artist} — {album}");
}
}
+
+ private static void Download(string username, string password, string album)
+ {
+ throw new NotImplementedException();
+ }
+
+ private static Option CreateOption(string name, string description)
+ {
+ return new Option(name, description)
+ {
+ IsRequired = true
+ };
+ }
}