metafates / mangal

📖 The most advanced (yet simple) cli manga downloader in the entire universe! Lua scrapers, export formats, anilist integration, fancy TUI and more!
MIT License
1.35k stars 51 forks source link

Cannot set any config to empty string #147

Open oae opened 1 year ago

oae commented 1 year ago

Describe the bug

When I try to update the config to an empty string, mangal panics with the following error.

➜  mangal config set --key "gen.author" --value ""
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/metafates/mangal/cmd.glob..func3(0x1d1c8e0?, {0x10183f8?, 0x4?, 0x4?})
    github.com/metafates/mangal/cmd/config.go:133 +0x829
github.com/spf13/cobra.(*Command).execute(0x1d1c8e0, {0xc000432c40, 0x4, 0x4})
    github.com/spf13/cobra@v1.6.1/command.go:920 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0x1d1c040)
    github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.6.1/command.go:968
github.com/metafates/mangal/cmd.Execute()
    github.com/metafates/mangal/cmd/root.go:112 +0x7a
main.main()

Reproduction steps

  1. Execute mangal config set --key "gen.author" --value ""

Expected behavior

The command should set the value to an empty string

Additional context

This happened after version 4.0.5

Operating System

Linux

metafates commented 1 year ago

Oh, that's weird, I'll take a look