-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from numtide/feat/show-unmatched
--on-unwatched
- Loading branch information
Showing
7 changed files
with
160 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
|
||
"github.com/alecthomas/kong" | ||
"github.com/charmbracelet/log" | ||
) | ||
|
||
var Options []kong.Option | ||
|
||
func init() { | ||
Options = []kong.Option{ | ||
kong.TypeMapper(reflect.TypeOf(log.DebugLevel), logLevelDecoder()), | ||
} | ||
} | ||
|
||
func logLevelDecoder() kong.MapperFunc { | ||
return func(ctx *kong.DecodeContext, target reflect.Value) error { | ||
t, err := ctx.Scan.PopValue("string") | ||
if err != nil { | ||
return err | ||
} | ||
var str string | ||
switch v := t.Value.(type) { | ||
case string: | ||
str = v | ||
default: | ||
return fmt.Errorf("expected a string but got %q (%T)", t, t.Value) | ||
} | ||
level, err := log.ParseLevel(str) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse '%v' as log level: %w", level, err) | ||
} | ||
target.Set(reflect.ValueOf(level)) | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters