|
1 | 1 | package main
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "flag" |
5 |
| - "fmt" |
6 |
| - "github.com/ctrf-io/go-ctrf-json-reporter/reporter" |
7 |
| - "os" |
| 4 | + "flag" |
| 5 | + "fmt" |
| 6 | + "github.com/ctrf-io/go-ctrf-json-reporter/ctrf" |
| 7 | + "github.com/ctrf-io/go-ctrf-json-reporter/reporter" |
| 8 | + "os" |
8 | 9 | )
|
9 | 10 |
|
10 | 11 | func main() {
|
11 |
| - var outputFile string |
12 |
| - var verbose bool |
13 |
| - flag.BoolVar(&verbose, "verbose", false, "Enable verbose output") |
14 |
| - flag.BoolVar(&verbose, "v", false, "Enable verbose output (shorthand)") |
15 |
| - flag.StringVar(&outputFile, "output", "ctrf-report.json", "The output file for the test results") |
16 |
| - flag.StringVar(&outputFile, "o", "ctrf-report.json", "The output file for the test results (shorthand)") |
| 12 | + var outputFile string |
| 13 | + var verbose bool |
| 14 | + flag.BoolVar(&verbose, "verbose", false, "Enable verbose output") |
| 15 | + flag.BoolVar(&verbose, "v", false, "Enable verbose output (shorthand)") |
| 16 | + flag.StringVar(&outputFile, "output", "ctrf-report.json", "The output file for the test results") |
| 17 | + flag.StringVar(&outputFile, "o", "ctrf-report.json", "The output file for the test results (shorthand)") |
17 | 18 |
|
18 |
| - var tempAppName, tempAppVersion, tempOSPlatform, tempOSRelease, tempOSVersion, tempBuildName, tempBuildNumber string |
| 19 | + var tempAppName, tempAppVersion, tempOSPlatform, tempOSRelease, tempOSVersion, tempBuildName, tempBuildNumber string |
19 | 20 |
|
20 |
| - flag.StringVar(&tempAppName, "appName", "", "The name of the application being tested.") |
21 |
| - flag.StringVar(&tempAppVersion, "appVersion", "", "The version of the application being tested.") |
22 |
| - flag.StringVar(&tempOSPlatform, "osPlatform", "", "The operating system platform (e.g., Windows, Linux).") |
23 |
| - flag.StringVar(&tempOSRelease, "osRelease", "", "The release version of the operating system.") |
24 |
| - flag.StringVar(&tempOSVersion, "osVersion", "", "The version number of the operating system.") |
25 |
| - flag.StringVar(&tempBuildName, "buildName", "", "The name of the build (e.g., feature branch name).") |
26 |
| - flag.StringVar(&tempBuildNumber, "buildNumber", "", "The build number or identifier.") |
| 21 | + flag.StringVar(&tempAppName, "appName", "", "The name of the application being tested.") |
| 22 | + flag.StringVar(&tempAppVersion, "appVersion", "", "The version of the application being tested.") |
| 23 | + flag.StringVar(&tempOSPlatform, "osPlatform", "", "The operating system platform (e.g., Windows, Linux).") |
| 24 | + flag.StringVar(&tempOSRelease, "osRelease", "", "The release version of the operating system.") |
| 25 | + flag.StringVar(&tempOSVersion, "osVersion", "", "The version number of the operating system.") |
| 26 | + flag.StringVar(&tempBuildName, "buildName", "", "The name of the build (e.g., feature branch name).") |
| 27 | + flag.StringVar(&tempBuildNumber, "buildNumber", "", "The build number or identifier.") |
27 | 28 |
|
28 |
| - flag.Parse() |
| 29 | + flag.Parse() |
29 | 30 |
|
30 |
| - var env *reporter.Environment |
| 31 | + var env *ctrf.Environment |
31 | 32 |
|
32 |
| - if tempAppName != "" || tempAppVersion != "" || tempOSPlatform != "" || |
33 |
| - tempOSRelease != "" || tempOSVersion != "" || tempBuildName != "" || tempBuildNumber != "" { |
34 |
| - env = &reporter.Environment{} |
| 33 | + if tempAppName != "" || tempAppVersion != "" || tempOSPlatform != "" || |
| 34 | + tempOSRelease != "" || tempOSVersion != "" || tempBuildName != "" || tempBuildNumber != "" { |
| 35 | + env = &ctrf.Environment{} |
35 | 36 |
|
36 |
| - if tempAppName != "" { |
37 |
| - env.AppName = &tempAppName |
38 |
| - } |
39 |
| - if tempAppVersion != "" { |
40 |
| - env.AppVersion = &tempAppVersion |
41 |
| - } |
42 |
| - if tempOSPlatform != "" { |
43 |
| - env.OSPlatform = &tempOSPlatform |
44 |
| - } |
45 |
| - if tempOSRelease != "" { |
46 |
| - env.OSRelease = &tempOSRelease |
47 |
| - } |
48 |
| - if tempOSVersion != "" { |
49 |
| - env.OSVersion = &tempOSVersion |
50 |
| - } |
51 |
| - if tempBuildName != "" { |
52 |
| - env.BuildName = &tempBuildName |
53 |
| - } |
54 |
| - if tempBuildNumber != "" { |
55 |
| - env.BuildNumber = &tempBuildNumber |
56 |
| - } |
57 |
| - } |
| 37 | + if tempAppName != "" { |
| 38 | + env.AppName = tempAppName |
| 39 | + } |
| 40 | + if tempAppVersion != "" { |
| 41 | + env.AppVersion = tempAppVersion |
| 42 | + } |
| 43 | + if tempOSPlatform != "" { |
| 44 | + env.OSPlatform = tempOSPlatform |
| 45 | + } |
| 46 | + if tempOSRelease != "" { |
| 47 | + env.OSRelease = tempOSRelease |
| 48 | + } |
| 49 | + if tempOSVersion != "" { |
| 50 | + env.OSVersion = tempOSVersion |
| 51 | + } |
| 52 | + if tempBuildName != "" { |
| 53 | + env.BuildName = tempBuildName |
| 54 | + } |
| 55 | + if tempBuildNumber != "" { |
| 56 | + env.BuildNumber = tempBuildNumber |
| 57 | + } |
| 58 | + } |
58 | 59 |
|
59 |
| - report, err := reporter.ParseTestResults(os.Stdin, verbose, env) |
60 |
| - if err != nil { |
61 |
| - fmt.Fprintf(os.Stderr, "Error parsing test results: %v\n", err) |
62 |
| - os.Exit(1) |
63 |
| - } |
| 60 | + report, err := reporter.ParseTestResults(os.Stdin, verbose, env) |
| 61 | + if err != nil { |
| 62 | + _, _ = fmt.Fprintf(os.Stderr, "Error parsing test results: %v\n", err) |
| 63 | + os.Exit(1) |
| 64 | + } |
64 | 65 |
|
65 |
| - err = reporter.WriteReportToFile(outputFile, report) |
66 |
| - if err != nil { |
67 |
| - fmt.Fprintf(os.Stderr, "Error writing the report to file: %v\n", err) |
68 |
| - os.Exit(1) |
69 |
| - } |
| 66 | + err = reporter.WriteReportToFile(outputFile, report) |
| 67 | + if err != nil { |
| 68 | + _, _ = fmt.Fprintf(os.Stderr, "Error writing the report to file: %v\n", err) |
| 69 | + os.Exit(1) |
| 70 | + } |
70 | 71 | }
|
0 commit comments