3 Commits

Author SHA1 Message Date
ad301e0ff2 Update Help Text 2021-05-16 17:21:20 +08:00
1f0aefb72d Update README.md 2021-05-16 17:18:37 +08:00
c71ad9cc79 Close #10 Drag to Decrypt 2021-05-16 17:15:52 +08:00
2 changed files with 27 additions and 8 deletions

View File

@ -1,18 +1,25 @@
# Unlock Music Project - CLI Edition
Original: Web Edition https://github.com/ix64/unlock-music
- [Release Download](https://github.com/unlock-music/cli/releases/latest)
## Features
- [x] All Algorithm Supported By `ix64/unlock-music`
- [ ] Complete Cover Image
- [ ] Parse Meta Data
- [ ] Complete Meta Data
## Hou to Build
- Requirements: **Golang 1.16**
1. Clone this repo `git clone https://github.com/unlock-music/cli && cd cli`
2. Build the executable `go build ./cmd/um`
2. Build the executable `go build ./cmd/um`
## How to use
- Drag the encrypted file to `um.exe` (Tested on Windows)
- Run: `./um [-o <output dir>] [-i] <input dir/file>`
- Use `./um -h` to show help menu

View File

@ -12,13 +12,12 @@ import (
"github.com/unlock-music/cli/internal/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
"log"
"os"
"path/filepath"
"strings"
)
var AppVersion = "0.0.3"
var AppVersion = "0.0.4"
func main() {
app := cli.App{
@ -27,23 +26,36 @@ func main() {
Usage: "Unlock your encrypted music file https://github.com/unlock-music/cli",
Version: AppVersion,
Flags: []cli.Flag{
&cli.StringFlag{Name: "input", Aliases: []string{"i"}, Usage: "path to input file or dir", Required: true},
&cli.StringFlag{Name: "output", Aliases: []string{"o"}, Usage: "path to output dir", Required: true},
&cli.StringFlag{Name: "input", Aliases: []string{"i"}, Usage: "path to input file or dir", Required: false},
&cli.StringFlag{Name: "output", Aliases: []string{"o"}, Usage: "path to output dir", Required: false},
},
Action: appMain,
Copyright: "Copyright (c) 2020 Unlock Music https://github.com/unlock-music/cli/blob/master/LICENSE",
Copyright: "Copyright (c) 2020 - 2021 Unlock Music https://github.com/unlock-music/cli/blob/master/LICENSE",
HideHelpCommand: true,
UsageText: "um -i /path/to/input -o /path/to/output/dir",
UsageText: "um [-o /path/to/output/dir] [-i] /path/to/input",
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
logging.Log().Fatal("run app failed", zap.Error(err))
}
}
func appMain(c *cli.Context) error {
input := c.String("input")
if input == "" && c.Args().Present() {
input = c.Args().Get(c.Args().Len() - 1)
}
output := c.String("output")
if output == "" {
var err error
output, err = os.Getwd()
if err != nil {
return err
}
}
inputStat, err := os.Stat(input)
if err != nil {
return err