mirror of
https://github.com/Superredstone/spotiflac-cli.git
synced 2026-03-07 20:18:07 +01:00
feat: first working version
This commit is contained in:
41
main.go
41
main.go
@@ -1,13 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/Superredstone/spotiflac-cli/app"
|
||||
"github.com/Superredstone/spotiflac-cli/lib"
|
||||
"github.com/Superredstone/spotiflac-cli/pkg"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var song_url string
|
||||
application := app.NewApp()
|
||||
startup()
|
||||
|
||||
|
||||
cmd := &cli.Command{
|
||||
Name: "spotiflac-cli",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "download",
|
||||
Usage: "Download a song/playlist",
|
||||
Destination: &song_url,
|
||||
},
|
||||
},
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
pkg.Download(application, song_url)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
if err := cmd.Run(context.Background(), os.Args); err != nil {
|
||||
log.Fatal(err)
|
||||
shutdown()
|
||||
}
|
||||
|
||||
shutdown()
|
||||
}
|
||||
|
||||
func startup() {
|
||||
if err := lib.InitHistoryDB("SpotiFLAC"); err != nil {
|
||||
log.Fatal("Failed to init history DB: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func shutdown() {
|
||||
lib.CloseHistoryDB()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user