This repository has been archived by the owner on Dec 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: enable running 'check' command (#16)
This PR refactors the donutdns standalone server to be able to run subcommands. The first subcommand added is 'check', which can be used to determine if a specified domain would be blocked or allowed by a donutdns server in accordance with a given configuration.
- Loading branch information
Showing
15 changed files
with
342 additions
and
147 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,36 @@ | ||
package output | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// Info represents any type that can log via Infof. | ||
type Info interface { | ||
Infof(string, ...any) | ||
} | ||
|
||
// Error represents any type that can log via Errorf. | ||
type Error interface { | ||
Errorf(string, ...any) | ||
} | ||
|
||
// CLI is a wrapper around fmt.Print functions for satisfying interfaces. | ||
type CLI struct{} | ||
|
||
func (o *CLI) print(msg string, args ...any) { | ||
s := fmt.Sprintf(msg, args...) | ||
fmt.Println(s) | ||
} | ||
|
||
func (o *CLI) Infof(msg string, args ...any) { | ||
o.print(msg, args...) | ||
} | ||
|
||
func (o *CLI) Errorf(msg string, args ...any) { | ||
o.print(msg, args...) | ||
} | ||
|
||
type Logger interface { | ||
Info | ||
Error | ||
} |
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
Oops, something went wrong.