-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support enabling debug-mode via the config file too
Now you can have termshark's deb web server start using --debug or by setting main.debug = true in the config file. The command-line setting takes precedence, if provided.
- Loading branch information
Showing
3 changed files
with
59 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2019-2020 Graham Clark. All rights reserved. Use of this source | ||
// code is governed by the MIT license that can be found in the LICENSE | ||
// file. | ||
// | ||
|
||
package cli | ||
|
||
//====================================================================== | ||
|
||
type TriState struct { | ||
Set bool | ||
Val bool | ||
} | ||
|
||
func (b *TriState) UnmarshalFlag(value string) error { | ||
switch value { | ||
case "true", "TRUE", "t", "T", "1", "y", "Y", "yes", "Yes", "YES": | ||
b.Set = true | ||
b.Val = true | ||
case "false", "FALSE", "f", "F", "0", "n", "N", "no", "No", "NO": | ||
b.Set = true | ||
b.Val = false | ||
default: | ||
b.Set = false | ||
} | ||
return nil | ||
} | ||
|
||
func (b TriState) MarshalFlag() string { | ||
if b.Set { | ||
if b.Val { | ||
return "true" | ||
} else { | ||
return "false" | ||
} | ||
} else { | ||
return "unset" | ||
} | ||
} | ||
|
||
//====================================================================== | ||
// Local Variables: | ||
// mode: Go | ||
// fill-column: 78 | ||
// End: |
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