Skip to content

Commit

Permalink
Moved version on its package, fixed typo and improved readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Girbons committed Nov 21, 2019
1 parent 84aeab6 commit 0153a53
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mangadex does not support `all` and `last` parameters.

# What's new

* added `-deamon` and `-timeout` flags
* added `-daemon` and `-timeout` flags

# Improvements

Expand Down
30 changes: 11 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
# get latest git tag
TAG = $$(git describe --abbrev=0 --tags)
# get current date and time
NOW = $$(date +'%Y-%m-%d_%T')
# use the linker to inject the informations
LDFLAGS = "-X main.release=${TAG} -X main.buildTime=${NOW}"
LDFLAGSWINDOWS = "-H windowsgui -X main.release=${TAG} -X main.buildTime=${NOW}"

help: # this command
help: # this command
# [generating help from tasks header]
@egrep '^[A-Za-z0-9_-]+:' Makefile

osx-build: # Creates Mac OSX
@GOOS=darwin GOARCH=amd64 go build -ldflags=${LDFLAGS} -o build/comics-downloader-osx ./cmd/downloader
@GOOS=darwin GOARCH=amd64 go build -o build/comics-downloader-osx ./cmd/downloader

windows-build: # Creates Windows
@GOOS=windows GOARCH=amd64 go build -ldflags=${LDFLAGS} -o build/comics-downloader.exe ./cmd/downloader
@GOOS=windows GOARCH=amd64 go build -o build/comics-downloader.exe ./cmd/downloader

linux-build: # Creates Linux
@GOOS=linux GOARCH=amd64 go build -ldflags=${LDFLAGS} -o build/comics-downloader ./cmd/downloader
@GOOS=linux GOARCH=amd64 go build -o build/comics-downloader ./cmd/downloader

linux-arm-build: # Creates Linux ARM
@GOOS=linux GOARCH=arm go build -ldflags=${LDFLAGS} -o build/comics-downloader-linux-arm ./cmd/downloader
@GOOS=linux GOARCH=arm go build -o build/comics-downloader-linux-arm ./cmd/downloader

linux-arm64-build: # Creates Linux ARM64
@GOOS=linux GOARCH=arm64 go build -ldflags=${LDFLAGS} -o build/comics-downloader-linux-arm64 ./cmd/downloader
@GOOS=linux GOARCH=arm64 go build -o build/comics-downloader-linux-arm64 ./cmd/downloader

osx-gui-build: # Creates OSX Gui
@GOOS=darwin GOARCH=amd64 go build -ldflags=${LDFLAGS} -o build/comics-downloader-gui-osx ./cmd/gui
osx-gui-build: # Creates OSX GUI
@GOOS=darwin GOARCH=amd64 go build -o build/comics-downloader-gui-osx ./cmd/gui

windows-gui-build: # Creates Window GUI executable
@CGO_ENABLED=1 GOOS=windows CC=x86_64-w64-mingw32-gcc go build -ldflags=${LDFLAGSWINDOWS} -o build/comics-downloader-gui-windows.exe ./cmd/gui
@CGO_ENABLED=1 GOOS=windows CC=x86_64-w64-mingw32-gcc go build -o build/comics-downloader-gui-windows.exe ./cmd/gui

linux-gui-build: # Creates LINUX executable
@fyne-cross --ldflags=${LDFLAGS} --output=comics-downloader-gui --targets=linux/amd64 ./cmd/gui
linux-gui-build: # Creates LINUX GUI executable
@fyne-cross --output=comics-downloader-gui --targets=linux/amd64 ./cmd/gui

builds: # Creates executables for OSX/Windows/Linux
@make osx-build
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ You can invoke the `--help`:
Download all issues of the Comic or Comics
-country string
Set the country to retrieve a manga, Used by MangaRock
-deamon
Run the download as deamon
-daemon
Run the download as daemon
-format string
Comic format output, supported formats are pdf,epub,cbr,cbz (default "pdf")
-images-format
Expand Down Expand Up @@ -128,18 +128,18 @@ The folder will be created if not already existing.
./comics-downloader -url=[your url] -output=[your path]
```

### Run as Deamon
### Run as daemon

You can run the CLI downloader as deamon using `-deamon` flag.
You can run the CLI downloader as daemon using `-daemon` flag.
works only if `-all` or `-last` flags are specified.

```bash
./comics-downloader -url=[your url] -deamon
./comics-downloader -url=[your url] -daemon
```
You can customize the deamon timeout using the `-timeout` flag.
You can customize the daemon timeout using the `-timeout` flag.

```bash
./comics-downloader -url=[your url] -deamon -timeout=300
./comics-downloader -url=[your url] -daemon -timeout=300
```

### Download Only the Images
Expand Down Expand Up @@ -176,7 +176,7 @@ Default is __jpg__.

## Contribuiting

Feel free to submit a pull request.
Feel free to submit a pull request, a guide to setup the development enviroment is available [here](docs/dev.md)

## License

Expand Down
6 changes: 3 additions & 3 deletions cmd/app/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func GuiRun(link, format, country, imagesFormat string, all, last, imagesOnly bo
}

// Run will start the CLI app
func Run(link, format, country, imagesFormat string, all, last, deamon, imagesOnly bool, timeout int, outputFolder string) {
func Run(link, format, country, imagesFormat string, all, last, daemon, imagesOnly bool, timeout int, outputFolder string) {
if all && last {
last = false
log.Warning("all and last are selected, all parameter will be used")
Expand All @@ -108,8 +108,8 @@ func Run(link, format, country, imagesFormat string, all, last, deamon, imagesOn
log.Fatal("url parameter is required")
}

// deamon is started only if `all` or `last` flags are used
if deamon && (all || last) {
// daemon is started only if `all` or `last` flags are used
if daemon && (all || last) {
for {
download(link, format, country, all, last, false, imagesOnly, imagesFormat, outputFolder)
time.Sleep(time.Duration(timeout) * time.Second)
Expand Down
16 changes: 5 additions & 11 deletions cmd/downloader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,26 @@ import (
"strings"

"github.com/Girbons/comics-downloader/cmd/app"
)

var (
// sha1 revision used to build the program
release string
// executable build date
buildTime string
"github.com/Girbons/comics-downloader/internal/version"
)

func main() {
all := flag.Bool("all", false, "Download all issues of the Comic or Comics")
country := flag.String("country", "", "Set the country to retrieve a manga, Used by MangaRock")
deamon := flag.Bool("deamon", false, "Run the download as deamon")
daemon := flag.Bool("daemon", false, "Run the download as daemon")
format := flag.String("format", "pdf", "Comic format output, supported formats are pdf,epub,cbr,cbz")
imagesOnly := flag.Bool("images-only", false, "Download comic/manga images")
imagesFormat := flag.String("images-format", "jpg", "To use with `images-only` flag, choose the image format, available png,jpeg,img")
last := flag.Bool("last", false, "Download the last Comic issue")
timeout := flag.Int("timeout", 600, "Timeout (seconds), specifies how often the downloader runs")
url := flag.String("url", "", "Comic URL or Comic URLS by separating each site with a comma without the use of spaces")
versionFlag := flag.Bool("version", false, "Display build date and release informations")
versionFlag := flag.Bool("version", false, "Display release version")
outputFolder := flag.String("output", "", "Folder where the comics will be saved")

flag.Parse()

if *versionFlag {
fmt.Printf("Built on %s from release %s\n", buildTime, release)
fmt.Printf("comics-downloader version %s", version.Tag)
os.Exit(0)
}

Expand All @@ -47,5 +41,5 @@ func main() {
}
}

app.Run(*url, *format, *country, *imagesFormat, *all, *last, *deamon, *imagesOnly, *timeout, *outputFolder)
app.Run(*url, *format, *country, *imagesFormat, *all, *last, *daemon, *imagesOnly, *timeout, *outputFolder)
}
5 changes: 2 additions & 3 deletions cmd/gui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fyne.io/fyne/layout"
"fyne.io/fyne/widget"
downloader "github.com/Girbons/comics-downloader/cmd/app"
"github.com/Girbons/comics-downloader/internal/version"
)

func watchLogs(logSection *widget.ScrollContainer, box *widget.Box) {
Expand All @@ -27,14 +28,12 @@ func appStatus(downloadButton *widget.Button) {
}
}

var release string // sha1 revision used to build the program

func main() {
options := []string{"pdf", "epub", "cbr", "cbz"}
imagesFormat := []string{"png", "jpg", "img"}

app := app.New()
w := app.NewWindow(fmt.Sprintf("Comics Downloader %s", release))
w := app.NewWindow(fmt.Sprintf("Comics Downloader %s", version.Tag))

urlEntry := widget.NewEntry()
urlEntry.SetPlaceHolder("Comic URL or URLs separated by a comma")
Expand Down
5 changes: 5 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package version

// Tag specifies the current release tag.
// It needs to be manually updated.
const Tag = "v0.17.1"

0 comments on commit 0153a53

Please sign in to comment.