Skip to content

Commit

Permalink
Modernize code
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 5, 2024
1 parent bb0eb1b commit e7186a1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"reflect"
"strings"
Expand Down Expand Up @@ -68,7 +67,7 @@ var (

func init() {
OsExiter = fakeOsExiter
terminal.Stdout = terminal.NewBufferedConsoleOutput(ioutil.Discard, ioutil.Discard)
terminal.Stdout = terminal.NewBufferedConsoleOutput(io.Discard, io.Discard)
terminal.Stderr = terminal.Stdout.Stderr
}

Expand Down Expand Up @@ -765,7 +764,7 @@ func TestAppNoHelpFlag(t *testing.T) {

HelpFlag = nil

app := &Application{Writer: ioutil.Discard}
app := &Application{Writer: io.Discard}
err := app.Run([]string{"test", "-h"})

if !strings.Contains(err.Error(), flag.ErrHelp.Error()) {
Expand Down
4 changes: 2 additions & 2 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package console
import (
"errors"
"flag"
"io/ioutil"
"io"
"strings"
"testing"

Expand Down Expand Up @@ -113,7 +113,7 @@ func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {

func TestFuzzyCommandNames(t *testing.T) {
app := Application{}
app.ErrWriter = ioutil.Discard
app.ErrWriter = io.Discard
projectList := &Command{Name: "project:list"}
projectLink := &Command{Name: "project:link"}
app.Commands = []*Command{
Expand Down
2 changes: 1 addition & 1 deletion context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (cs *ContextSuite) TestContext_Set_AppFlags(c *C) {

app := &Application{
Commands: []*Command{
&Command{
{
Name: "foo",
Action: func(ctx *Context) error {
err := ctx.Set("log-level", "4")
Expand Down
4 changes: 2 additions & 2 deletions flags_enhancement.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package console
import (
"flag"
"fmt"
"io/ioutil"
"io"
"os"
"reflect"
"strings"
Expand Down Expand Up @@ -99,7 +99,7 @@ func (c *Command) fixArgs(args []string) []string {
}

func parseArgs(arguments []string, fs *flag.FlagSet) (*flag.FlagSet, error) {
fs.SetOutput(ioutil.Discard)
fs.SetOutput(io.Discard)
err := errors.WithStack(fs.Parse(arguments))
if err != nil {
return fs, err
Expand Down
4 changes: 2 additions & 2 deletions help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package console
import (
"bytes"
"flag"
"io/ioutil"
"io"
"strings"
"testing"
)
Expand Down Expand Up @@ -119,7 +119,7 @@ func Test_Version_Custom_Flags(t *testing.T) {

func Test_helpCommand_Action_ErrorIfNoTopic(t *testing.T) {
app := &Application{}
app.Writer, app.ErrWriter = ioutil.Discard, ioutil.Discard
app.Writer, app.ErrWriter = io.Discard, io.Discard

set := flag.NewFlagSet("test", 0)
set.Parse([]string{"foo"})
Expand Down
4 changes: 2 additions & 2 deletions output_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package console

import (
"flag"
"io/ioutil"
"io"
"os"
"strconv"

Expand All @@ -39,7 +39,7 @@ func (r *quietValue) Set(s string) error {
return errors.WithStack(err)
}
if quiet {
terminal.Stdout = terminal.NewBufferedConsoleOutput(ioutil.Discard, ioutil.Discard)
terminal.Stdout = terminal.NewBufferedConsoleOutput(io.Discard, io.Discard)
} else {
terminal.Stdout = terminal.DefaultStdout
}
Expand Down

0 comments on commit e7186a1

Please sign in to comment.