Skip to content

Commit

Permalink
Generate Docs Script
Browse files Browse the repository at this point in the history
Generate Binaries Command Improved
  • Loading branch information
WillJCJ committed Jul 1, 2018
1 parent 46457f8 commit bcd2d48
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
github.com

# Complied binaries
cmd/param/param-*
bin/

### macOS ###
# General
Expand Down
29 changes: 29 additions & 0 deletions build/build_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

PLATFORMS="darwin/amd64 linux/amd64"

type setopt >/dev/null 2>&1

SCRIPT_NAME=`basename "$0"`
FAILURES=""

if [ -z "${GOPATH}" ]; then
GOPATH="~/go"
fi
BIN_PATH="${GOPATH}/src/github.com/willjcj/param/bin"

for PLATFORM in $PLATFORMS; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
BIN_FILENAME="${BIN_PATH}/param-${GOOS}-${GOARCH}"

CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} $@"
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
done

# eval errors
if [[ "${FAILURES}" != "" ]]; then
echo ""
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
exit 1
fi
25 changes: 25 additions & 0 deletions build/generate_docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"go/build"
"log"
"os"
"path"

"github.com/spf13/cobra/doc"
"github.com/willjcj/param/cmd"
)

func main() {
gopath := os.Getenv("GOPATH")
if gopath == "" {
gopath = build.Default.GOPATH
}

docsPath := path.Join(gopath, "src", "github.com", "willjcj", "param", "docs")

err := doc.GenMarkdownTree(cmd.RootCmd, docsPath)
if err != nil {
log.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ var addCmd = &cobra.Command{
}

func init() {
rootCmd.AddCommand(addCmd)
RootCmd.AddCommand(addCmd)
}
2 changes: 1 addition & 1 deletion cmd/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var copyCmd = &cobra.Command{
}

func init() {
rootCmd.AddCommand(copyCmd)
RootCmd.AddCommand(copyCmd)
copyCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Also print parameter value to the stdout.")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var listCmd = &cobra.Command{
}

func init() {
rootCmd.AddCommand(listCmd)
RootCmd.AddCommand(listCmd)

listCmd.Flags().StringVarP(&prefixes, "prefix", "p", "", "Prefixes to fileter by")
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import (

var cfgFile string

var rootCmd = &cobra.Command{
var RootCmd = &cobra.Command{
Use: "param",
Short: "Tools to improve Parameter Store on the command line.",
Long: "Param is a cli tool to improve interacting with AWS Parameter Store.",
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
// This is called by main.main(). It only needs to happen once to the RootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
Expand All @@ -32,7 +32,7 @@ func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.param.yaml)")
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.param.yaml)")
}

// initConfig reads in config file and ENV variables if set.
Expand Down
22 changes: 22 additions & 0 deletions docs/param.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## param

Tools to improve Parameter Store on the command line.

### Synopsis

Param is a cli tool to improve interacting with AWS Parameter Store.

### Options

```
--config string config file (default is $HOME/.param.yaml)
-h, --help help for param
```

### SEE ALSO

* [param add](param_add.md) - Add a paramter to Parameter Store.
* [param copy](param_copy.md) - Copy a parameter to clipboard.
* [param list](param_list.md) - List parameters in Parameter Store.

###### Auto generated by spf13/cobra on 1-Jul-2018
30 changes: 30 additions & 0 deletions docs/param_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## param add

Add a paramter to Parameter Store.

### Synopsis

Add a paramter to Parameter Store.
Doesn't work yet.

```
param add [flags]
```

### Options

```
-h, --help help for add
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.param.yaml)
```

### SEE ALSO

* [param](param.md) - Tools to improve Parameter Store on the command line.

###### Auto generated by spf13/cobra on 1-Jul-2018
30 changes: 30 additions & 0 deletions docs/param_copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## param copy

Copy a parameter to clipboard.

### Synopsis

Copy the specified SSM Parameter from Paramter Store to your clipboard.

```
param copy parameter_name [flags]
```

### Options

```
-h, --help help for copy
-v, --verbose Also print parameter value to the stdout.
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.param.yaml)
```

### SEE ALSO

* [param](param.md) - Tools to improve Parameter Store on the command line.

###### Auto generated by spf13/cobra on 1-Jul-2018
31 changes: 31 additions & 0 deletions docs/param_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## param list

List parameters in Parameter Store.

### Synopsis

List all parameters from parameter store with an optional prefix.
Results are sorted in alphabetical order.

```
param list [flags]
```

### Options

```
-h, --help help for list
-p, --prefix string Prefixes to fileter by
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.param.yaml)
```

### SEE ALSO

* [param](param.md) - Tools to improve Parameter Store on the command line.

###### Auto generated by spf13/cobra on 1-Jul-2018

0 comments on commit bcd2d48

Please sign in to comment.