|
62 | 62 | )
|
63 | 63 |
|
64 | 64 | func (c *config) prepare() {
|
| 65 | + if c.Pkg == "" { |
| 66 | + c.Pkg = "slogx" |
| 67 | + } |
65 | 68 | if len(c.Levels) > 0 {
|
66 | 69 | c.Imports = append(c.Imports, "log/slog", "fmt", "strings")
|
67 | 70 | }
|
@@ -97,22 +100,22 @@ func readFlags(args []string) (*config, error) {
|
97 | 100 | fmt.Println(`Usage: sloggen [flags]
|
98 | 101 |
|
99 | 102 | Flags:
|
100 |
| - -config <path> read config from the file instead of flags |
101 |
| - -dir <path> change the working directory before generating files |
102 |
| - -pkg <name> the name for the generated package (default: slogx) |
103 |
| - -i <import> add import |
104 |
| - -l <name:severity> add level |
105 |
| - -c <key> add constant |
106 |
| - -a <key:type> add attribute |
107 |
| - -logger generate a custom Logger type |
108 |
| - -api <any|attr> the API style for the Logger's methods (default: any) |
109 |
| - -ctx add context.Context to the Logger's methods |
110 |
| - -h, -help print this message and quit`) |
| 103 | + -config <path> read config from the file instead of flags |
| 104 | + -dir <path> change the working directory before generating files |
| 105 | + -pkg <name> the name for the generated package (default: slogx) |
| 106 | + -i <import> add import |
| 107 | + -l <name:severity> add level |
| 108 | + -c <key> add constant |
| 109 | + -a <key:type> add attribute |
| 110 | + -logger generate a custom Logger type |
| 111 | + -api <any|attr> the API style for the Logger's methods (default: any) |
| 112 | + -ctx add context.Context to the Logger's methods |
| 113 | + -h, -help print this message and quit`) |
111 | 114 | }
|
112 | 115 |
|
113 | 116 | fs.StringVar(&cfg.path, "config", "", "")
|
114 | 117 | fs.StringVar(&cfg.dir, "dir", "", "")
|
115 |
| - fs.StringVar(&cfg.Pkg, "pkg", "slogx", "") |
| 118 | + fs.StringVar(&cfg.Pkg, "pkg", "", "") |
116 | 119 |
|
117 | 120 | fs.Func("i", "", func(s string) error {
|
118 | 121 | cfg.Imports = append(cfg.Imports, s)
|
|
0 commit comments