Skip to content

Commit

Permalink
Use PrintErrln instead of PrintErr (#96)
Browse files Browse the repository at this point in the history
* Use PrintErrln instead of PrintErr

* Add an example command
  • Loading branch information
toshimaru authored Oct 19, 2020
1 parent 6904632 commit 24ad66e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var rootCmd = &cobra.Command{
Long: "Colored cat command which supports syntax highlighting.",
Example: `$ nyan FILE
$ nyan FILE1 FILE2 FILE3
$ nyan -t solarized-dark FILE`,
$ nyan -t solarized-dark FILE
$ nyan -l go FILE`,
RunE: cmdMain,
SilenceErrors: true,
SilenceUsage: false,
Expand Down Expand Up @@ -66,7 +67,7 @@ func cmdMain(cmd *cobra.Command, args []string) (err error) {

if len(args) < 1 || args[0] == "-" {
if data, err = ioutil.ReadAll(cmd.InOrStdin()); err != nil {
cmd.PrintErr("Error: ", err, "\n")
cmd.PrintErrln("Error:", err)
return
}
if language != "" {
Expand All @@ -79,8 +80,7 @@ func cmdMain(cmd *cobra.Command, args []string) (err error) {
var lastErr error
for _, filename := range args {
if data, err = ioutil.ReadFile(filename); err != nil {
// FIXME: use PrintErrln after upstream is fixed
cmd.PrintErr("Error: ", err, "\n")
cmd.PrintErrln("Error:", err)
lastErr = err
continue
}
Expand Down

0 comments on commit 24ad66e

Please sign in to comment.