Skip to content

Commit 812ae3b

Browse files
author
Katrina Owen
committed
Move shared package variables to cmd helper file
The Root command is just a command (though admittedly a somewhat special one). The cmd.go file is where we're putting shared stuff.
1 parent 42e56dc commit 812ae3b

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

cmd/cmd.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,27 @@ package cmd
33
import (
44
"fmt"
55

6+
"io"
7+
68
"github.com/exercism/cli/config"
79
"github.com/spf13/viper"
810
)
911

12+
var (
13+
// BinaryName is the name of the app.
14+
// By default this is exercism, but people
15+
// are free to name this however they want.
16+
// The usage examples and help strings should reflect
17+
// the actual name of the binary.
18+
BinaryName string
19+
// Out is used to write to information.
20+
Out io.Writer
21+
// Err is used to write errors.
22+
Err io.Writer
23+
// In is used to provide mocked test input (i.e. for prompts).
24+
In io.Reader
25+
)
26+
1027
const msgWelcomePleaseConfigure = `
1128
1229
Welcome to Exercism!

cmd/root.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"fmt"
5-
"io"
65
"os"
76
"runtime"
87

@@ -13,21 +12,6 @@ import (
1312
"github.com/spf13/cobra"
1413
)
1514

16-
var (
17-
// BinaryName is the name of the app.
18-
// By default this is exercism, but people
19-
// are free to name this however they want.
20-
// The usage examples and help strings should reflect
21-
// the actual name of the binary.
22-
BinaryName string
23-
// Out is used to write to information.
24-
Out io.Writer
25-
// Err is used to write errors.
26-
Err io.Writer
27-
// In is used to provide mocked test input (i.e. for prompts).
28-
In io.Reader
29-
)
30-
3115
// RootCmd represents the base command when called without any subcommands.
3216
var RootCmd = &cobra.Command{
3317
Use: BinaryName,

0 commit comments

Comments
 (0)