Skip to content

Commit

Permalink
Updated action.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Nov 1, 2021
1 parent 72e147a commit 3a2099e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package cmd
import (
"bufio"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"io/ioutil"
"log"
"os"
"strconv"
)

var actionFileName string
Expand All @@ -32,19 +34,19 @@ var outputFileName string
type Input struct {
Description string `yaml:"description"`
Required bool `yaml:"required"`
Default string `yaml:"default"`
Default string `yaml:"default,omitempty"`
}

type Output struct {
Description string `yaml:"description"`
Value string `yaml:"default"`
Value string `yaml:"default,omitempty"`
}

type Action struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Inputs map[string]Input `yaml:"inputs"`
Outputs map[string]Output `yaml:"outputs"`
Inputs map[string]Input `yaml:"inputs,omitempty"`
Outputs map[string]Output `yaml:"outputs,omitempty"`
}

func (a *Action) getAction() *Action {
Expand Down Expand Up @@ -86,10 +88,16 @@ var rootCmd = &cobra.Command{
fmt.Printf("Name: %s \n", action.Name)
fmt.Printf("Description: %s\n", action.Description)

table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Input", "Required", "Default", "Description"})

for _, input := range action.Inputs {
fmt.Printf("Input: %v\n", input)
row := []string{"", strconv.FormatBool(input.Required), input.Default, input.Description}
table.Append(row)
}

table.Render()

for _, output := range action.Outputs {
fmt.Printf("Output: %v\n", output)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/tj-actions/auto-doc
go 1.14

require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/spf13/cobra v1.2.1
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand All @@ -187,6 +189,8 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down

0 comments on commit 3a2099e

Please sign in to comment.