-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from yurvon-screamo/3-autorun-test-from-dev-mode
Create dev mode
- Loading branch information
Showing
39 changed files
with
461 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package cmd | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/yurvon-screamo/utsukushii/dev_mode" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type devModeYamlConfig struct { | ||
Cmd string `yaml:"cmd"` | ||
Lang string `yaml:"lang"` | ||
Title string `yaml:"title"` | ||
Coverage int16 `yaml:"coverage"` | ||
ServeAddress string `yaml:"addr"` | ||
IgnoreOpenBrowser bool `yaml:"ignore_open"` | ||
} | ||
|
||
func handleDevMode(cmd *cobra.Command, args []string) { | ||
rawConfig, err := os.ReadFile(devModeConfig) | ||
if err != nil { | ||
log.Fatalf("error read config: %v", err) | ||
} | ||
|
||
config := devModeYamlConfig{} | ||
err = yaml.Unmarshal([]byte(rawConfig), &config) | ||
if err != nil { | ||
log.Fatalf("error unmarshal: %v", err) | ||
} | ||
|
||
if config.ServeAddress == "" { | ||
config.ServeAddress = ":8080" | ||
} | ||
if config.Title == "" { | ||
config.Title = "Utsukushii dev" | ||
} | ||
|
||
devModeConfig := &dev_mode.DevModeConfig{ | ||
Cmd: config.Cmd, | ||
Lang: config.Lang, | ||
Title: config.Title, | ||
Coverage: config.Coverage, | ||
ServeAddress: config.ServeAddress, | ||
OpenBrowser: !config.IgnoreOpenBrowser, | ||
} | ||
|
||
err = dev_mode.RunDevMode(devModeConfig) | ||
if err != nil { | ||
log.Fatalf("run dev mode: %v", err) | ||
} | ||
} | ||
|
||
var devModeConfig string | ||
|
||
var devModeCmd = &cobra.Command{ | ||
Use: "dev", | ||
Short: "Serve and open UI in dev mode", | ||
Long: `Run your tests from utsukushii report and get feedback immediately`, | ||
Run: handleDevMode, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(devModeCmd) | ||
|
||
devModeCmd.Flags().StringVarP(&devModeConfig, "config", "c", "utsukushii-dev.yaml", "Path to dev mode config") | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev_mode | ||
|
||
type DevModeConfig struct { | ||
Cmd string | ||
Lang string | ||
Title string | ||
Coverage int16 | ||
ServeAddress string | ||
OpenBrowser bool | ||
} | ||
|
||
const ( | ||
golang = "go" | ||
dotnet = ".net" | ||
) |
Oops, something went wrong.