feat: statistics flag, commented some more
This commit is contained in:
@@ -5,21 +5,21 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Defines the consumption of different types of input sources.
|
||||
// A method of extracting input from the user.
|
||||
type Source interface {
|
||||
// Get the data.
|
||||
Pull() (string, error)
|
||||
// Fetch data from this source.
|
||||
Extract() (string, error)
|
||||
}
|
||||
|
||||
// A source coming from a string.
|
||||
type StringSource struct{ data string }
|
||||
// A source defined by a string.
|
||||
type StringSource struct{ Data string }
|
||||
|
||||
func (s StringSource) Pull() (string, error) { return s.data, nil }
|
||||
func (s StringSource) Extract() (string, error) { return s.Data, nil }
|
||||
|
||||
// A source coming from standard input.
|
||||
// A source pulling from standard input.
|
||||
type StdinSource struct{}
|
||||
|
||||
func (s StdinSource) Pull() (string, error) {
|
||||
func (s StdinSource) Extract() (string, error) {
|
||||
data, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user