Alter 2 files

Update `main.go`
Update `selections.go`
This commit is contained in:
akp 2022-12-03 13:53:53 +00:00
parent 92dc12ff15
commit bdab5c23c6
No known key found for this signature in database
GPG key ID: AA5726202C8879B7
2 changed files with 24 additions and 17 deletions

View file

@ -2,10 +2,12 @@ package main
import (
"fmt"
"github.com/codemicro/adventOfCode/runtime/benchmark"
au "github.com/logrusorgru/aurora"
"io/ioutil"
"path/filepath"
"strings"
"github.com/codemicro/adventOfCode/runtime/benchmark"
au "github.com/logrusorgru/aurora"
"github.com/alexflint/go-arg"
"github.com/codemicro/adventOfCode/runtime/challenge"
@ -66,6 +68,18 @@ func run() error {
return err
}
fmt.Print(
au.Bold(
fmt.Sprintf(
"%s-%d %s (%s)\n\n",
strings.TrimPrefix(selectedYear, "challenges/"),
selectedChallenge.Number,
selectedChallenge.Name,
runners.RunnerNames[selectedImplementation],
),
),
)
runner := runners.Available[selectedImplementation](selectedChallenge.Dir)
if err := runner.Start(); err != nil {
return err
@ -75,7 +89,6 @@ func run() error {
_ = runner.Cleanup()
}()
if args.Visualise {
id := "vis"
r, err := runner.Run(&runners.Task{
@ -108,15 +121,16 @@ func run() error {
} else {
if err := runTests(runner, challengeInfo); err != nil {
return err
}
if !args.TestOnly {
if err := runMainTasks(runner, challengeInputString); err != nil {
if err := runTests(runner, challengeInfo); err != nil {
return err
}
}}
if !args.TestOnly {
if err := runMainTasks(runner, challengeInputString); err != nil {
return err
}
}
}
return nil
}

View file

@ -55,7 +55,6 @@ func selectYear(dir string) (string, error) {
if args.Year != "" {
for _, x := range opts {
if x == args.Year {
fmt.Printf("Selecting year %s\n", args.Year)
return filepath.Join(dir, x), nil
}
}
@ -66,7 +65,6 @@ func selectYear(dir string) (string, error) {
if x := len(opts); x == 1 {
selectedYearIndex = 0
fmt.Printf("Automatically selecting year %s\n", opts[selectedYearIndex])
} else {
selectedYearIndex, err = userSelect("Which year do you want to use?", opts)
if err != nil {
@ -91,7 +89,6 @@ func selectChallenge(dir string) (*challenge.Challenge, error) {
if args.ChallengeDay != nil {
for _, ch := range challenges {
if ch.Number == *args.ChallengeDay {
fmt.Printf("Selecting day %d (%s)\n", ch.Number, ch.Name)
return ch, nil
}
}
@ -102,8 +99,6 @@ func selectChallenge(dir string) (*challenge.Challenge, error) {
if x := len(challenges); x == 1 {
selectedChallengeIndex = 0
c := challenges[0]
fmt.Printf("Automatically selecting day %d (%s)\n", c.Number, c.Name)
} else {
var opts []string
for _, c := range challenges {
@ -133,7 +128,6 @@ func selectImplementation(ch *challenge.Challenge) (string, error) {
if args.Implementation != "" {
for _, im := range implementations {
if strings.EqualFold(im, args.Implementation) {
fmt.Printf("Selecting %s implementation\n", runners.RunnerNames[im])
return im, nil
}
}
@ -144,7 +138,6 @@ func selectImplementation(ch *challenge.Challenge) (string, error) {
if x := len(implementations); x == 1 {
selectedImplementationIndex = 0
fmt.Printf("Automatically selecting %s implementation\n", runners.RunnerNames[implementations[0]])
} else {
var opts []string
for _, i := range implementations {