Skip to content

Commit 8267a34

Browse files
authored
Merge pull request #22 from chermehdi/refactoring/fmt
gofmt everything and delete useless test
2 parents 77c1f63 + 6fb072d commit 8267a34

File tree

7 files changed

+33
-49
lines changed

7 files changed

+33
-49
lines changed

commands/copy.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package commands
22

33
import (
4-
"github.com/urfave/cli/v2"
4+
"fmt"
5+
"github.com/atotto/clipboard"
56
"github.com/chermehdi/egor/config"
67
"github.com/fatih/color"
7-
"github.com/atotto/clipboard"
8+
"github.com/urfave/cli/v2"
9+
"io/ioutil"
810
"os"
911
"path"
10-
"io/ioutil"
11-
"fmt"
1212
)
1313

14-
// Load the content of a given file
14+
// Load the content of a given file
1515
func GetFileContent(filePath string) (string, error) {
1616
filebytes, err := ioutil.ReadFile(filePath)
1717
if err != nil {

commands/parse.go

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func SerializeTask(meta EgorMeta) (string, error) {
3030
return buffer.String(), nil
3131
}
3232

33-
3433
func CreateDirectoryStructure(task Task, config Config, rootDir string) (string, error) {
3534
taskDir := path.Join(rootDir, task.Name)
3635
if err := os.Mkdir(taskDir, 0777); err != nil {

commands/printcase.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
package commands
22

33
import (
4+
"bufio"
45
"errors"
5-
"github.com/urfave/cli/v2"
6+
"fmt"
67
"github.com/chermehdi/egor/config"
78
"github.com/chermehdi/egor/utils"
8-
"github.com/fatih/color"
9+
"github.com/fatih/color"
10+
"github.com/urfave/cli/v2"
911
"os"
1012
"path"
11-
"fmt"
12-
"bufio"
1313
"strconv"
1414
)
1515

1616
func GetTestCase(egorMeta config.EgorMeta, id int) *TestCaseIO {
1717
var testCase *TestCaseIO
1818
for _, input := range egorMeta.Inputs {
1919
if input.GetId() == id {
20-
testCase = &TestCaseIO {
21-
Id : input.GetId(),
22-
Name : input.Name,
23-
InputPath : input.Path,
20+
testCase = &TestCaseIO{
21+
Id: input.GetId(),
22+
Name: input.Name,
23+
InputPath: input.Path,
2424
OutputPath: "",
25-
Custom: input.Custom,
25+
Custom: input.Custom,
2626
}
2727

2828
break
@@ -32,12 +32,12 @@ func GetTestCase(egorMeta config.EgorMeta, id int) *TestCaseIO {
3232
if testCase == nil {
3333
return nil
3434
}
35-
35+
3636
for _, output := range egorMeta.Outputs {
3737
if output.Name == testCase.Name {
3838
testCase.OutputPath = output.Path
3939
}
40-
}
40+
}
4141

4242
if testCase == nil {
4343
return nil
@@ -46,7 +46,7 @@ func GetTestCase(egorMeta config.EgorMeta, id int) *TestCaseIO {
4646
}
4747

4848
func PrintTestCaseInput(testCase *TestCaseIO) {
49-
49+
5050
file, err := config.OpenFileFromPath(testCase.InputPath)
5151
if err != nil {
5252
color.Red("Failed to read test case input")
@@ -57,7 +57,7 @@ func PrintTestCaseInput(testCase *TestCaseIO) {
5757
fmt.Println(scanner.Text())
5858
}
5959
}
60-
60+
6161
}
6262

6363
func PrintTestCaseOutput(testCase *TestCaseIO) {
@@ -109,7 +109,7 @@ func PrintCaseAction(context *cli.Context) error {
109109
color.Red("Failed to load egor MetaData ")
110110
return err
111111
}
112-
112+
113113
testCase := GetTestCase(metaData, id)
114114
if testCase == nil {
115115
color.Red(fmt.Sprintf("Could not find test case with id = %d", id))
@@ -123,15 +123,15 @@ func PrintCaseAction(context *cli.Context) error {
123123
if !context.Bool("input-only") {
124124
PrintTestCaseOutput(testCase)
125125
}
126-
126+
127127
return nil
128128
}
129129

130130
// Command to print a test case. this command can be used to print inputs and/or outputs
131131
// to the consol. The user can choose to print the input only or the output only. The
132132
// user should provide a valid test id.
133133
// Running this command will fetch egor meta data, get the test case with the given id,
134-
// and then print the content of the input and/or of the output files.
134+
// and then print the content of the input and/or of the output files.
135135
var PrintCaseCommand = cli.Command{
136136
Name: "printcase",
137137
Aliases: []string{"pc"},

commands/printcase_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ func TestGetTestCase(t *testing.T) {
1414
assert.Equal(t, testCase.InputPath, metaData.Inputs[0].Path)
1515
assert.Equal(t, testCase.OutputPath, metaData.Outputs[0].Path)
1616
assert.Equal(t, testCase.Custom, metaData.Inputs[0].Custom)
17-
}
17+
}

config/meta.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ import (
88
"io"
99
"os"
1010
"path"
11-
"strings"
1211
"strconv"
12+
"strings"
1313
)
1414

1515
type IoFile struct {
16-
Name string
17-
Path string
18-
Custom bool
16+
Name string
17+
Path string
18+
Custom bool
1919
}
2020

2121
func NewIoFile(fileName, filePath string, customCase bool) IoFile {
2222
return IoFile{
23-
Name: fileName,
24-
Path: filePath,
25-
Custom: customCase,
23+
Name: fileName,
24+
Path: filePath,
25+
Custom: customCase,
2626
}
2727
}
2828

2929
func (ioFile *IoFile) GetId() int {
3030
tokens := strings.Split(ioFile.Name, "-")
3131
id, err := strconv.Atoi(tokens[1])
3232
if err != nil {
33-
return 0
33+
return 0
3434
}
3535
return id
3636
}

main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package main
22

33
import (
44
"bytes"
5-
"html/template"
6-
"log"
7-
"os"
85
"github.com/chermehdi/egor/commands"
96
"github.com/chermehdi/egor/config"
107
"github.com/urfave/cli/v2"
8+
"html/template"
9+
"log"
10+
"os"
1111
)
1212

1313
const Egor = `

utils/formatter_test.go

-15
This file was deleted.

0 commit comments

Comments
 (0)