Skip to content

Commit

Permalink
Merge pull request #113 from metafates/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
metafates authored Oct 25, 2022
2 parents ddd3323 + 0f839d7 commit 97206a1
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 679 deletions.
14 changes: 0 additions & 14 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,11 @@ release:

name_template: "{{.ProjectName}} v{{.Version}}"
header: |
To update:
```
mangal update
```
To install:
```sh
curl -sSL mangal.metafates.one/install | sh
```
<details>
<summary>If you have any problems updating</summary>
Run the install script (you can run it multiple times):
```sh
curl -sSL mangal.metafates.one/install | sh
```
</details>
## What's new?
footer: |
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to
[Semantic Versioning](https://semver.org).

## 3.14.1

- Mark flags as required for `inline anilist` commands
- Remove `update` command [Why?](https://github.com/metafates/mangal/discussions/112)
- `mangal version` will notify if new version is available
- Use correct page image extension for custom sources #110

## 3.14.0

- New commands related to the anilist manga linkage. Now you can set what anilist manga should be linked with what titles by id. See `mangal inline anilist` for more information. #106
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ the official bucket)

Thanks to [@T-Dynamos](https://github.com/T-Dynamos) for adding it to the [termux-packages](https://github.com/termux/termux-packages)

> `mangal update` command may not work properly
```shell
pkg install mangal
```
Expand All @@ -93,8 +91,6 @@ pkg install mangal

Install using [Nix](https://nixos.org/download.html#download-nix). Thanks to [@bertof](https://github.com/bertof) for adding it to the [nixpkgs](https://github.com/NixOS/nixpkgs)

> `mangal update` command may not work properly
```shell
# NixOS
nix-env -iA nixos.mangal
Expand Down
17 changes: 13 additions & 4 deletions cmd/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ var inlineCmd = &cobra.Command{
Manga selectors:
first - first manga in the list
last - last manga in the list
[number] - select manga by index
[number] - select manga by index (starting from 0)
Chapter selectors:
first - first chapter in the list
last - last chapter in the list
all - all chapters in the list
[number] - select chapter by index
[number] - select chapter by index (starting from 0)
[from]-[to] - select chapters by range
@[substring]@ - select chapters by name substring
When using the json flag manga selector could be omitted. That way, it will select all mangas`,

Example: "mangal inline --source Manganelo --query \"death note\" --manga first --chapters \"@Vol.1 @\" -d",
Example: "https://github.com/metafates/mangal/wiki/Inline-mode",
PreRun: func(cmd *cobra.Command, args []string) {
json, _ := cmd.Flags().GetBool("json")

Expand Down Expand Up @@ -146,6 +146,11 @@ func init() {
var inlineAnilistSearchCmd = &cobra.Command{
Use: "search",
Short: "Search anilist manga by name",
PreRun: func(cmd *cobra.Command, args []string) {
if !cmd.Flags().Changed("name") && !cmd.Flags().Changed("id") {
handleErr(errors.New("name or id flag is required"))
}
},
Run: func(cmd *cobra.Command, args []string) {
mangaName := lo.Must(cmd.Flags().GetString("name"))
mangaId := lo.Must(cmd.Flags().GetInt("id"))
Expand All @@ -169,7 +174,8 @@ var inlineAnilistSearchCmd = &cobra.Command{
func init() {
inlineAnilistCmd.AddCommand(inlineAnilistGetCmd)

inlineAnilistGetCmd.Flags().StringP("name", "n", "", "manga name to get bind for")
inlineAnilistGetCmd.Flags().StringP("name", "n", "", "manga name to get the bind for")
lo.Must0(inlineAnilistGetCmd.MarkFlagRequired("name"))
}

var inlineAnilistGetCmd = &cobra.Command{
Expand All @@ -195,6 +201,9 @@ func init() {
inlineAnilistBindCmd.Flags().StringP("name", "n", "", "manga name")
inlineAnilistBindCmd.Flags().IntP("id", "i", 0, "anilist manga id")

lo.Must0(inlineAnilistBindCmd.MarkFlagRequired("name"))
lo.Must0(inlineAnilistBindCmd.MarkFlagRequired("id"))

inlineAnilistBindCmd.MarkFlagsRequiredTogether("name", "id")
}

Expand Down
21 changes: 0 additions & 21 deletions cmd/update.go

This file was deleted.

72 changes: 39 additions & 33 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package cmd

import (
"fmt"
"github.com/metafates/mangal/icon"
"github.com/metafates/mangal/style"
"github.com/metafates/mangal/updater"
"github.com/metafates/mangal/util"
"os"
"runtime"
"strings"
"text/template"

"github.com/metafates/mangal/constant"
"github.com/metafates/mangal/updater"
"github.com/spf13/cobra"
)

Expand All @@ -22,57 +25,60 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of mangal",
Long: `All software has versions. This is mangal's`,
Run: func(cmd *cobra.Command, args []string) {
var installedWith string
erase := util.PrintErasable(fmt.Sprintf("%s Checking if new version is available...", icon.Get(icon.Progress)))
var newVersion string

switch updater.DetectInstallationMethod() {
case updater.Homebrew:
installedWith = "Homebrew"
case updater.Scoop:
installedWith = "Scoop"
case updater.Termux:
installedWith = "Termux"
case updater.Standalone:
installedWith = "Standalone"
case updater.Go:
installedWith = "From source (" + runtime.Version() + ")"
default:
installedWith = "Unknown"
version, err := updater.LatestVersion()
if err == nil {
comp, err := util.CompareVersions(constant.Version, version)
if err == nil && comp == -1 {
newVersion = version
}
}

erase()

versionInfo := struct {
Version string
InstalledWith string
OS string
Arch string
BuiltAt string
BuiltBy string
Revision string
App string
Version string
OS string
Arch string
BuiltAt string
BuiltBy string
Revision string
App string
NewVersion string
}{
Version: constant.Version,
App: constant.Mangal,
InstalledWith: installedWith,
OS: runtime.GOOS,
Arch: runtime.GOARCH,
BuiltAt: strings.TrimSpace(constant.BuiltAt),
BuiltBy: constant.BuiltBy,
Revision: constant.Revision,
Version: constant.Version,
App: constant.Mangal,
OS: runtime.GOOS,
Arch: runtime.GOARCH,
BuiltAt: strings.TrimSpace(constant.BuiltAt),
BuiltBy: constant.BuiltBy,
Revision: constant.Revision,
NewVersion: newVersion,
}

t, err := template.New("version").Funcs(map[string]any{
"faint": style.Faint,
"bold": style.Bold,
"magenta": style.Magenta,
"green": style.Green,
"repeat": strings.Repeat,
"concat": func(a, b string) string {
return a + b
},
}).Parse(`{{ magenta "▇▇▇" }} {{ magenta .App }}
{{ faint "Version" }} {{ bold .Version }}
{{ faint "Git Commit" }} {{ bold .Revision }}
{{ faint "Build Date" }} {{ bold .BuiltAt }}
{{ faint "Built By" }} {{ bold .BuiltBy }}
{{ faint "Installed With" }} {{ bold .InstalledWith }}
{{ faint "Platform" }} {{ bold .OS }}/{{ bold .Arch }}
`)
{{ if not (eq .NewVersion "") }}
{{ green "▇▇▇" }} New version available {{ bold .NewVersion }}
{{ faint (concat "https://github.com/metafates/mangal/releases/tag/v" .NewVersion) }}
{{ end }}`)
handleErr(err)
handleErr(t.Execute(cmd.OutOrStdout(), versionInfo))
},
Expand Down
2 changes: 1 addition & 1 deletion constant/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package constant

const (
Mangal = "mangal"
Version = "3.14.0"
Version = "3.14.1"
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
)
10 changes: 2 additions & 8 deletions provider/custom/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/samber/lo"
lua "github.com/yuin/gopher-lua"
"net/url"
"path/filepath"
"strconv"
"strings"
)
Expand Down Expand Up @@ -133,21 +134,14 @@ func pageFromTable(table *lua.LTable, chapter *source.Chapter) (page *source.Pag
page.Index = uint16(num)
return nil
}},
"extension": {A: lua.LTString, B: false, C: func(v string) error {
if !strings.HasPrefix(v, ".") {
v = "." + v
}

page.Extension = v
return nil
}, D: ".jpg"},
}

err = translate(table, mappings)
if err != nil {
return
}

page.Extension = filepath.Ext(page.URL)
chapter.Pages = append(chapter.Pages, page)
return
}
87 changes: 0 additions & 87 deletions updater/detect.go

This file was deleted.

Loading

0 comments on commit 97206a1

Please sign in to comment.