Skip to content

Commit

Permalink
feat: doc field for command description
Browse files Browse the repository at this point in the history
feat: yaml syntax color for dry run output
  • Loading branch information
Fabian Simon committed May 12, 2023
1 parent 0479419 commit e25af50
Show file tree
Hide file tree
Showing 39 changed files with 3,529 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ vars:
AB: {{$bval}}B
---
install:
doc: I'm a description what this command do
script:
- touch test.gomake.txt
- echo "Hallo" > test.gomake.txt
Expand Down Expand Up @@ -113,7 +114,7 @@ There is a [Dockerimage](https://hub.docker.com/r/fasibio/gomake)
You can use same stage for different commands

```yaml
buildBin:
buildBin:
stage: build
color: "{{$root.Colors.purple}}"
script:
Expand Down
11 changes: 6 additions & 5 deletions command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
type MakeStruct map[string]Operation

type Operation struct {
Script []string
Image *DockerOperation
On_Failure []string
Stage string
Color string
Script []string `yaml:"script,omitempty"`
Doc string `yaml:"doc,omitempty"`
Image *DockerOperation `yaml:"image,omitempty"`
On_Failure []string `yaml:"on_failure,omitempty"`
Stage string `yaml:"stage,omitempty"`
Color string `yaml:"color,omitempty"`
}

type DockerOperation struct {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/Masterminds/sprig/v3 v3.2.3
github.com/andreazorzetto/yh v0.4.0
github.com/pkg/errors v0.9.1
github.com/schollz/closestmatch v2.1.0+incompatible
github.com/urfave/cli/v2 v2.23.7
Expand All @@ -17,6 +18,7 @@ require (
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/andreazorzetto/yh v0.4.0 h1:kXQJxhT7v9/JqUNifD+yIBRLKXDWeBgO2/UjxwRQsto=
github.com/andreazorzetto/yh v0.4.0/go.mod h1:c7MhXod3cApIEJDb9VSXA9cZVVaEZbvW+GhMPiVg2tM=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -15,6 +17,8 @@ github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
Expand Down
1 change: 1 addition & 0 deletions gomake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ buildAll:

build:
stage: b
doc: create a Binary for each GOOS and GOARCH
color: "{{$root.Colors.purple}}"
script:
- mkdir {{.Vars.dist}}
Expand Down
8 changes: 6 additions & 2 deletions interpreter/dryRun.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package interpreter

import (
"bytes"
"fmt"

"github.com/andreazorzetto/yh/highlight"
"github.com/fasibio/gomake/command"
"gopkg.in/yaml.v2"
)
Expand All @@ -25,6 +27,8 @@ func (i Interpreter) printDryRun(command []StageOperationWrapper, variables map[
if err != nil {
return err
}
fmt.Println(string(out))
return nil
reader := bytes.NewReader(out)
r, err := highlight.Highlight(reader)
fmt.Print(r)
return err
}
1 change: 0 additions & 1 deletion interpreter/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func (r *Interpreter) GetExecuteTemplate(file string, extraVariables map[string]

varStr, err := r.getParsedTemplate("gomake_vars", varCommandArr[0], TemplateData{Env: env, Vars: tempVar, Colors: getColorKeyMap()})

log.Println(string(varStr))
if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (r *Runner) List(c *cli.Context) error {
}
fmt.Println("List of executed Commands (for run):")
for k := range list {
fmt.Println(k)
fmt.Printf("%s %s \n", k, list[k].Doc)
}

fmt.Println("\nList of executed Stages (for srun):")
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/andreazorzetto/yh/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

201 changes: 201 additions & 0 deletions vendor/github.com/andreazorzetto/yh/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions vendor/github.com/andreazorzetto/yh/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e25af50

Please sign in to comment.