David K. Bainbridge | 215e024 | 2017-09-05 23:18:24 -0700 | [diff] [blame] | 1 | // Copyright 2016 Claudemiro Alves Feitosa Neto. All rights reserved. |
| 2 | // Use of this source code is governed by a MIT-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Package autoload configure the banner loader with defaults |
| 6 | // Import the package. Thats it. |
| 7 | package autoload |
| 8 | |
| 9 | import ( |
| 10 | "flag" |
| 11 | "os" |
| 12 | |
| 13 | "github.com/dimiro1/banner" |
| 14 | "github.com/mattn/go-colorable" |
| 15 | ) |
| 16 | |
| 17 | func init() { |
| 18 | var ( |
| 19 | filename string |
| 20 | isEnabled bool |
| 21 | isColorEnabled bool |
| 22 | ) |
| 23 | |
| 24 | flag.StringVar(&filename, "banner", "banner.txt", "banner.txt file") |
| 25 | flag.BoolVar(&isEnabled, "show-banner", true, "print the banner?") |
| 26 | flag.BoolVar(&isColorEnabled, "ansi", true, "ansi colors enabled?") |
| 27 | |
| 28 | flag.Parse() |
| 29 | |
| 30 | in, err := os.Open(filename) |
| 31 | |
| 32 | if in != nil { |
| 33 | defer in.Close() |
| 34 | } |
| 35 | |
| 36 | if err != nil { |
| 37 | return |
| 38 | } |
| 39 | |
| 40 | banner.Init(colorable.NewColorableStdout(), isEnabled, isColorEnabled, in) |
| 41 | } |