-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Control input source & output/error destination
- Loading branch information
1 parent
454504e
commit ec4bb8f
Showing
6 changed files
with
120 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
package main | ||
|
||
import "incipher.io/shamir/cmd" | ||
import ( | ||
"os" | ||
|
||
"incipher.io/shamir/cmd" | ||
"incipher.io/shamir/utils" | ||
) | ||
|
||
func main() { | ||
cmd.Execute() | ||
inputSource := os.Stdin | ||
outputDestination := os.Stdout | ||
errorDestination := os.Stderr | ||
|
||
// Generate root command | ||
rootCommand := cmd.GenerateRootCommand( | ||
inputSource, | ||
outputDestination, | ||
errorDestination, | ||
) | ||
|
||
// Run root command | ||
err := rootCommand.Execute() | ||
if err != nil { | ||
utils.ExitWithError(errorDestination, err) | ||
} | ||
} |
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,24 @@ | ||
package utils | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
// Returns an io.ReadCloser with a no-op Close method wrapping the provided reader. | ||
func NopReadCloser(reader io.Reader) io.ReadCloser { | ||
return io.NopCloser(reader) | ||
} | ||
|
||
// Returns an io.WriteCloser with a no-op Close method wrapping the provided writer. | ||
func NopWriteCloser(writer io.Writer) io.WriteCloser { | ||
return &WriteCloser{Writer: writer} | ||
} | ||
|
||
func (writeCloser *WriteCloser) Close() error { | ||
// Noop | ||
return nil | ||
} | ||
|
||
type WriteCloser struct { | ||
io.Writer | ||
} |
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