Change log level when files are not found (#138)

* Change log level when files are not found

* Adding new flag CI
This commit is contained in:
Mateus Miranda 2021-12-02 09:38:47 +01:00 committed by GitHub
parent f3ff1dc098
commit ac8133a8b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,7 @@ type Flags struct {
TargetURL string `docopt:"-l"` TargetURL string `docopt:"-l"`
BaseURL string `docopt:"--base-url"` BaseURL string `docopt:"--base-url"`
Config string `docopt:"--config"` Config string `docopt:"--config"`
Ci bool `docopt:"--ci"`
} }
const ( const (
@ -70,6 +71,7 @@ Options:
[default: auto] [default: auto]
-c --config <path> Use the specified configuration file. -c --config <path> Use the specified configuration file.
[default: $HOME/.config/mark] [default: $HOME/.config/mark]
--ci Runs on CI mode. It won't fail if files are not found.
-h --help Show this message. -h --help Show this message.
-v --version Show version. -v --version Show version.
` `
@ -121,7 +123,12 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
if len(files) == 0 { if len(files) == 0 {
log.Fatal("No files matched") msg := "No files matched"
if flags.Ci {
log.Warning(msg)
} else {
log.Fatal(msg)
}
} }
// Loop through files matched by glob pattern // Loop through files matched by glob pattern