8
8
"os"
9
9
"path"
10
10
"io/ioutil"
11
+ "fmt"
11
12
)
12
13
13
14
// Load the content of a given file
@@ -24,45 +25,45 @@ func GetFileContent(filePath string) (string, error) {
24
25
func CopyAction (context * cli.Context ) error {
25
26
cwd , err := os .Getwd ()
26
27
if err != nil {
27
- color .Red ("Failed to list test cases!" )
28
+ color .Red (fmt . Sprintf ( "Failed to list test cases : %s" , err . Error ()) )
28
29
return err
29
30
}
30
31
31
32
configuration , err := config .LoadDefaultConfiguration ()
32
33
if err != nil {
33
- color .Red ("Failed to load egor configuration" )
34
+ color .Red (fmt . Sprintf ( "Failed to load egor configuration: %s" , err . Error ()) )
34
35
return err
35
36
}
36
37
37
38
configFileName := configuration .ConfigFileName
38
39
metaData , err := config .LoadMetaFromPath (path .Join (cwd , configFileName ))
39
40
if err != nil {
40
- color .Red ("Failed to load egor MetaData " )
41
+ color .Red (fmt . Sprintf ( "Failed to load egor MetaData : %s" , err . Error ()) )
41
42
return err
42
43
}
43
44
44
45
taskFile := metaData .TaskFile
45
46
taskContent , err := GetFileContent (taskFile )
46
47
if err != nil {
47
- color .Red ("Failed to load task file content" )
48
+ color .Red (fmt . Sprintf ( "Failed to load task file content : %s" , err . Error ()) )
48
49
return err
49
50
}
50
51
51
52
err = clipboard .WriteAll (taskContent )
52
53
if err != nil {
53
- color .Red ("Failed to copy task content to clipboard" )
54
+ color .Red (fmt . Sprintf ( "Failed to copy task content to clipboard : %s" , err . Error ()) )
54
55
return err
55
56
}
56
57
57
- color .Green ("Done! " )
58
+ color .Green ("Task copied to clipboard successfully " )
58
59
return nil
59
60
}
60
61
61
62
// Command to copy task source file to clipboard for easy submit.
62
63
// Running this command will fetch egor meta data, get the content of the task source
63
64
// and then copy the content to the clipboard.
64
65
var CopyCommand = cli.Command {
65
- Name : "showcases " ,
66
+ Name : "copy " ,
66
67
Aliases : []string {"cp" },
67
68
Usage : "copy task file into clipboad" ,
68
69
UsageText : "list meta data about of the tests cases in the current task" ,
0 commit comments