Skip to content

Commit

Permalink
Multiple report support (#12)
Browse files Browse the repository at this point in the history
* incorrect tabs on yaml template

* added support for multiple reports and started mac work
  • Loading branch information
madhuravius authored Jul 19, 2022
1 parent d1cf8aa commit b2856ef
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ steps:
description: starting clingy flow
command: echo
args:
- "Starting"`
- "Starting"`

// initCmd - inits a .clingy.yaml for use in the current path
var initCmd = &cobra.Command{
Expand Down
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var (
outputPath = "./output"
// inputFile - a path that contains an input file to digest and run clingy against
inputFile = "./.clingy.yaml"
// reportStyle - output format to share screenshots
reportStyle = "html-simple"
)

// getOutputPath - a string that generates a union of an (dynamic) output path and build number for artifacts
Expand Down Expand Up @@ -82,6 +84,7 @@ func init() {

rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "enable debug logs")
rootCmd.PersistentFlags().StringVarP(&outputPath, "outputPath", "o", outputPath, "build path that dumps outputs")
rootCmd.PersistentFlags().StringVarP(&inputFile, "inputFile", "i", inputFile, "inputFile representing a .clingy.yaml")
rootCmd.PersistentFlags().StringVarP(&inputFile, "inputFile", "i", inputFile, "input file representing a .clingy.yaml")
rootCmd.PersistentFlags().StringVarP(&reportStyle, "reportStyle", "r", reportStyle, "report style to output to (choices: 'html-simple', 'images-only')")
rootCmd.Flags().SortFlags = true
}
28 changes: 18 additions & 10 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,29 @@ var runCmd = &cobra.Command{
args = []string{}
}
imagePath := internal.CaptureWindow(logger, getOutputPath(), step.Command, args, strconv.Itoa(idx), ".jpg")
if step.Label != "" {
internal.AddLabelToImage(logger, step.Label, imagePath)
}
if step.Description != "" {
internal.AddDescriptionToImage(logger, step.Description, imagePath)

if reportStyle == "images-only" {
if step.Label != "" {
internal.AddLabelToImage(logger, step.Label, imagePath)
}
if step.Description != "" {
internal.AddDescriptionToImage(logger, step.Description, imagePath)
}
}
clingyData.Steps[idx].ImageOutput = fmt.Sprintf("%s%s", strconv.Itoa(idx), ".jpg")
}

internal.ClearTerminal()
fmt.Println("Completed clingy run, generating report.")

if err := internal.GenerateHTMLReport(logger, clingyData, fmt.Sprintf("%s/index.html", getOutputPath())); err != nil {
fmt.Println("Error in generating report")
os.Exit(1)
switch reportStyle {
case "images-only":
fmt.Println("Completed clingy run, generated images.")
case "html-simple":
fmt.Println("Completed clingy run, generating report.")

if err := internal.GenerateHTMLReport(logger, clingyData, fmt.Sprintf("%s/index.html", getOutputPath())); err != nil {
fmt.Println("Error in generating report")
os.Exit(1)
}
}
},
}
Binary file added docs/example-outputs/0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/example-outputs/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/example-outputs/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/example-outputs/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/example-outputs/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions docs/example-outputs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<html lang="en" data-theme="dark">
<head><title>Clingy Report - clingy flow</title></head>
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
<body>
<main class="container">
<hgroup>
<h1>
Clingy Report - clingy flow
</h1>
<h2>
Steps:
</h2>
</hgroup>

<div>
<hgroup>
<h3>
#0 start
</h3>
<h4>
starting clingy flow
</h4>
</hgroup>
<img alt="screenshot of start" src="0.jpg" />
</div>

<div>
<hgroup>
<h3>
#1 build clingy
</h3>
<h4>
building clingy with Makefile target
</h4>
</hgroup>
<img alt="screenshot of build clingy" src="1.jpg" />
</div>

<div>
<hgroup>
<h3>
#2 clingy init
</h3>
<h4>
displaying printout of only calling clingy
</h4>
</hgroup>
<img alt="screenshot of clingy init" src="2.jpg" />
</div>

<div>
<hgroup>
<h3>
#3 clingy help
</h3>
<h4>
display help text for clingy
</h4>
</hgroup>
<img alt="screenshot of clingy help" src="3.jpg" />
</div>

<div>
<hgroup>
<h3>
#4 finish
</h3>
<h4>
finished clingy flow
</h4>
</hgroup>
<img alt="screenshot of finish" src="4.jpg" />
</div>

</main>
</body>
</html>
42 changes: 22 additions & 20 deletions internal/templates/simple-report.template.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<html lang="en">
<html lang="en" data-theme="dark">
<head><title>Clingy Report - {{.Label}}</title></head>
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
<body>
<hgroup>
<h1>
Clingy Report - {{.Label}}
</h1>
<h2>
Steps:
</h2>
</hgroup>
{{range $idx, $step := .Steps}}
<div>
<main class="container">
<hgroup>
<h3>
#{{$idx}} {{$step.Label}}
</h3>
<h4>
{{$step.Description}}
</h4>
<h1>
Clingy Report - {{.Label}}
</h1>
<h2>
Steps:
</h2>
</hgroup>
<img alt="screenshot of {{$step.Label}}" src="{{$step.ImageOutput}}" />
</div>
{{end}}
{{range $idx, $step := .Steps}}
<div>
<hgroup>
<h3>
#{{$idx}} {{$step.Label}}
</h3>
<h4>
{{$step.Description}}
</h4>
</hgroup>
<img alt="screenshot of {{$step.Label}}" src="{{$step.ImageOutput}}" />
</div>
{{end}}
</main>
</body>
</html>
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Requires the following dependencies for this to even run:

* [imagemagick](https://imagemagick.org/script/download.php)

#### MacOS

__Warning__: On macOS - this also requires you to use [GetWindowID](https://github.com/smokris/GetWindowID)
and expects this to be installed.

### Running in docker

This can be run in docker. Instructions TBD
Expand Down

0 comments on commit b2856ef

Please sign in to comment.