Skip to content

Commit

Permalink
add hof/dm/log command for printing diff history; cleanup hof/dm subc…
Browse files Browse the repository at this point in the history
…md aliases

Signed-off-by: Tony Worm <tony@hofstadter.io>
  • Loading branch information
verdverm committed Dec 30, 2021
1 parent 0d37fc7 commit 6bc4c41
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 10 deletions.
1 change: 1 addition & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/datamodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func init() {
DatamodelCmd.AddCommand(cmddatamodel.ListCmd)
DatamodelCmd.AddCommand(cmddatamodel.InfoCmd)
DatamodelCmd.AddCommand(cmddatamodel.DiffCmd)
DatamodelCmd.AddCommand(cmddatamodel.LogCmd)
DatamodelCmd.AddCommand(cmddatamodel.HistoryCmd)
DatamodelCmd.AddCommand(cmddatamodel.CheckpointCmd)

Expand Down
1 change: 1 addition & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/datamodel/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var CheckpointCmd = &cobra.Command{

Aliases: []string{
"cp",
"x",
},

Short: "calculate a migration changeset for a data model",
Expand Down
2 changes: 1 addition & 1 deletion .hof/shadow/Cli/cmd/hof/cmd/datamodel/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var InfoCmd = &cobra.Command{
Use: "info",

Aliases: []string{
"s",
"i",
},

Short: "print details for data models",
Expand Down
2 changes: 1 addition & 1 deletion .hof/shadow/Cli/cmd/hof/cmd/datamodel/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var ListCmd = &cobra.Command{
Use: "list",

Aliases: []string{
"l",
"ls",
},

Short: "find and display data models",
Expand Down
73 changes: 73 additions & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/datamodel/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package cmddatamodel

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

var logLong = `show the current diff for a data model`

func LogRun(args []string) (err error) {

// you can safely comment this print out
fmt.Println("not implemented")

return err
}

var LogCmd = &cobra.Command{

Use: "log",

Aliases: []string{
"l",
},

Short: "show the current diff for a data model",

Long: logLong,

PreRun: func(cmd *cobra.Command, args []string) {

},

Run: func(cmd *cobra.Command, args []string) {
var err error

// Argument Parsing

err = LogRun(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}

func init() {
extra := func(cmd *cobra.Command) bool {

return false
}

ohelp := LogCmd.HelpFunc()
ousage := LogCmd.UsageFunc()
help := func(cmd *cobra.Command, args []string) {
if extra(cmd) {
return
}
ohelp(cmd, args)
}
usage := func(cmd *cobra.Command) error {
if extra(cmd) {
return nil
}
return ousage(cmd)
}

LogCmd.SetHelpFunc(help)
LogCmd.SetUsageFunc(usage)

}
1 change: 1 addition & 0 deletions cmd/hof/cmd/datamodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func init() {
DatamodelCmd.AddCommand(cmddatamodel.ListCmd)
DatamodelCmd.AddCommand(cmddatamodel.InfoCmd)
DatamodelCmd.AddCommand(cmddatamodel.DiffCmd)
DatamodelCmd.AddCommand(cmddatamodel.LogCmd)
DatamodelCmd.AddCommand(cmddatamodel.HistoryCmd)
DatamodelCmd.AddCommand(cmddatamodel.CheckpointCmd)

Expand Down
3 changes: 2 additions & 1 deletion cmd/hof/cmd/datamodel/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var CheckpointCmd = &cobra.Command{

Aliases: []string{
"cp",
"x",
},

Short: "calculate a migration changeset for a data model",
Expand Down Expand Up @@ -75,4 +76,4 @@ func init() {
CheckpointCmd.SetHelpFunc(help)
CheckpointCmd.SetUsageFunc(usage)

}
}
4 changes: 2 additions & 2 deletions cmd/hof/cmd/datamodel/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var InfoCmd = &cobra.Command{
Use: "info",

Aliases: []string{
"s",
"i",
},

Short: "print details for data models",
Expand Down Expand Up @@ -75,4 +75,4 @@ func init() {
InfoCmd.SetHelpFunc(help)
InfoCmd.SetUsageFunc(usage)

}
}
4 changes: 2 additions & 2 deletions cmd/hof/cmd/datamodel/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var ListCmd = &cobra.Command{
Use: "list",

Aliases: []string{
"l",
"ls",
},

Short: "find and display data models",
Expand Down Expand Up @@ -75,4 +75,4 @@ func init() {
ListCmd.SetHelpFunc(help)
ListCmd.SetUsageFunc(usage)

}
}
73 changes: 73 additions & 0 deletions cmd/hof/cmd/datamodel/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package cmddatamodel

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

var logLong = `show the current diff for a data model`

func LogRun(args []string) (err error) {

// you can safely comment this print out
fmt.Println("not implemented")

return err
}

var LogCmd = &cobra.Command{

Use: "log",

Aliases: []string{
"l",
},

Short: "show the current diff for a data model",

Long: logLong,

PreRun: func(cmd *cobra.Command, args []string) {

},

Run: func(cmd *cobra.Command, args []string) {
var err error

// Argument Parsing

err = LogRun(args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}

func init() {
extra := func(cmd *cobra.Command) bool {

return false
}

ohelp := LogCmd.HelpFunc()
ousage := LogCmd.UsageFunc()
help := func(cmd *cobra.Command, args []string) {
if extra(cmd) {
return
}
ohelp(cmd, args)
}
usage := func(cmd *cobra.Command) error {
if extra(cmd) {
return nil
}
return ousage(cmd)
}

LogCmd.SetHelpFunc(help)
LogCmd.SetUsageFunc(usage)

}
12 changes: 9 additions & 3 deletions design/cli/cmds/datamodel.cue
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ import (
Commands: [{
Name: "list"
Usage: "list"
Aliases: ["l"]
Aliases: ["ls"]
Short: "find and display data models"
Long: Short
}, {
Name: "info"
Usage: "info"
Aliases: ["s"]
Aliases: ["i"]
Short: "print details for data models"
Long: Short
}, {
Expand All @@ -75,6 +75,12 @@ import (
Aliases: ["d"]
Short: "show the current diff for a data model"
Long: Short
}, {
Name: "log"
Usage: "log"
Aliases: ["l"]
Short: "show the current diff for a data model"
Long: Short
}, {
Name: "history"
Usage: "history"
Expand All @@ -84,7 +90,7 @@ import (
}, {
Name: "checkpoint"
Usage: "checkpoint"
Aliases: ["cp"]
Aliases: ["cp", "x"]
Short: "calculate a migration changeset for a data model"
Long: Short
}]
Expand Down

0 comments on commit 6bc4c41

Please sign in to comment.