Skip to content

Commit

Permalink
Configure cobra using standard layout
Browse files Browse the repository at this point in the history
This sets cobra up using the standard approach (the default when
running `cobra init`

It's then easier to run the app with commands such as:

`go run main.go run`

Signed-off-by: Luke Hinds <luke@redhat.com>
  • Loading branch information
Luke Hinds committed Oct 8, 2021
1 parent 5de8337 commit c64f64d
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LAYOUT_TMPL := ./certs/layout.tmpl

build: modules
@mkdir -p bin
@go build -o ./bin/in-toto ./cmd/in-toto
@go build -o ./bin/in-toto ./cmd

modules:
@go mod tidy
Expand Down
2 changes: 1 addition & 1 deletion cmd/in-toto/completion.go → cmd/completion.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion cmd/in-toto/gendoc.go → cmd/gendoc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"github.com/spf13/cobra"
Expand Down
5 changes: 0 additions & 5 deletions cmd/in-toto/main.go

This file was deleted.

25 changes: 0 additions & 25 deletions cmd/in-toto/verify.sh

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/in-toto/key.go → cmd/key.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion cmd/in-toto/record.go → cmd/record.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/in-toto/root.go → cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/in-toto/run.go → cmd/run.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/in-toto/sign.go → cmd/sign.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/in-toto/verify.go → cmd/verify.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"fmt"
Expand Down
11 changes: 11 additions & 0 deletions cmd/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e

# Verify that generated Markdown docs are up-to-date.
tmpdir=$(mktemp -d)
go run ./cmd gendoc --dir "$tmpdir"
echo "###########################################"
echo "If diffs are found, run: go run ./cmd gendoc"
echo "###########################################"
diff -Naur "$tmpdir" doc/
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/in-toto/in-toto-golang/cmd"
)

func main() {
cmd.Execute()
}

0 comments on commit c64f64d

Please sign in to comment.