Skip to content

Commit

Permalink
wips: datamodel, structural; bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed Oct 30, 2020
1 parent b8b7317 commit b1c7ddd
Show file tree
Hide file tree
Showing 30 changed files with 358 additions and 229 deletions.
9 changes: 9 additions & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/datamodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ import (

"github.com/hofstadter-io/hof/cmd/hof/cmd/datamodel"

"github.com/hofstadter-io/hof/cmd/hof/flags"

"github.com/hofstadter-io/hof/cmd/hof/ga"
)

var datamodelLong = `create, view, diff, calculate / migrate, and manage your data models`

func init() {

DatamodelCmd.PersistentFlags().StringSliceVarP(&(flags.DatamodelPflags.Datamodels), "datamodel", "D", nil, "Datamodels for the datamodel commands")
DatamodelCmd.PersistentFlags().StringSliceVarP(&(flags.DatamodelPflags.Modelsets), "modelset", "M", nil, "Modelsets for the datamodel commands")
DatamodelCmd.PersistentFlags().StringSliceVarP(&(flags.DatamodelPflags.Models), "model", "m", nil, "Models for the datamodel commands")
}

var DatamodelCmd = &cobra.Command{

Use: "datamodel",
Expand Down
2 changes: 2 additions & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"

"github.com/hofstadter-io/hof/cmd/hof/verinfo"
)

Expand Down Expand Up @@ -55,6 +56,7 @@ var UpdateCmd = &cobra.Command{
Long: UpdateLong,

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

ga.SendCommandPath("update")

},
Expand Down
1 change: 1 addition & 0 deletions .hof/shadow/Cli/cmd/hof/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"

"github.com/hofstadter-io/hof/cmd/hof/verinfo"
)

Expand Down
9 changes: 9 additions & 0 deletions .hof/shadow/Cli/cmd/hof/flags/datamodel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package flags

type DatamodelPflagpole struct {
Datamodels []string
Modelsets []string
Models []string
}

var DatamodelPflags DatamodelPflagpole
9 changes: 9 additions & 0 deletions cmd/hof/cmd/datamodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ import (

"github.com/hofstadter-io/hof/cmd/hof/cmd/datamodel"

"github.com/hofstadter-io/hof/cmd/hof/flags"

"github.com/hofstadter-io/hof/cmd/hof/ga"
)

var datamodelLong = `create, view, diff, calculate / migrate, and manage your data models`

func init() {

DatamodelCmd.PersistentFlags().StringSliceVarP(&(flags.DatamodelPflags.Datamodels), "datamodel", "D", nil, "Datamodels for the datamodel commands")
DatamodelCmd.PersistentFlags().StringSliceVarP(&(flags.DatamodelPflags.Modelsets), "modelset", "M", nil, "Modelsets for the datamodel commands")
DatamodelCmd.PersistentFlags().StringSliceVarP(&(flags.DatamodelPflags.Models), "model", "m", nil, "Models for the datamodel commands")
}

var DatamodelCmd = &cobra.Command{

Use: "datamodel",
Expand Down
5 changes: 3 additions & 2 deletions cmd/hof/cmd/datamodel/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/flags"
"github.com/hofstadter-io/hof/cmd/hof/ga"

"github.com/hofstadter-io/hof/lib/datamodel"
Expand All @@ -18,7 +19,7 @@ func GetRun(args []string) (err error) {
// you can safely comment this print out
// fmt.Println("not implemented")

err = datamodel.RunGetFromArgs(args)
err = datamodel.RunGetFromArgs(args, flags.DatamodelPflags)

return err
}
Expand Down Expand Up @@ -86,4 +87,4 @@ func init() {
GetCmd.SetHelpFunc(thelp)
GetCmd.SetUsageFunc(tusage)

}
}
2 changes: 2 additions & 0 deletions cmd/hof/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"

"github.com/hofstadter-io/hof/cmd/hof/verinfo"
)

Expand Down Expand Up @@ -55,6 +56,7 @@ var UpdateCmd = &cobra.Command{
Long: UpdateLong,

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

ga.SendCommandPath("update")

},
Expand Down
1 change: 1 addition & 0 deletions cmd/hof/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"

"github.com/hofstadter-io/hof/cmd/hof/ga"

"github.com/hofstadter-io/hof/cmd/hof/verinfo"
)

Expand Down
9 changes: 9 additions & 0 deletions cmd/hof/flags/datamodel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package flags

type DatamodelPflagpole struct {
Datamodels []string
Modelsets []string
Models []string
}

var DatamodelPflags DatamodelPflagpole
28 changes: 28 additions & 0 deletions design/cli/cmds/datamodel.cue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ import (

OmitRun: true

Pflags: [...schema.#Flag] & [
{
Name: "Datamodels"
Long: "datamodel"
Short: "D"
Type: "[]string"
Default: "nil"
Help: "Datamodels for the datamodel commands"
},
{
Name: "modelsets"
Long: "modelset"
Short: "M"
Type: "[]string"
Default: "nil"
Help: "Modelsets for the datamodel commands"
},
{
Name: "models"
Long: "model"
Short: "m"
Type: "[]string"
Default: "nil"

Help: "Models for the datamodel commands"
},
]

Commands: [{
TBD: "α"
Name: "create"
Expand Down
2 changes: 1 addition & 1 deletion design/cli/pflags.cue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

#CliPflags: [...schema.#Flag] & [
// Labels will be core
{
{
Name: "labels"
Long: "label"
Short: "l"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hofstadter-io/hof

go 1.14
go 1.15

require (
cuelang.org/go v0.2.1
Expand Down
3 changes: 1 addition & 2 deletions lib/cuetils/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ func CueSyntax(val cue.Value, opts []cue.Option) (ast.Node) {
cue.Definitions(true),
cue.Docs(true),
cue.Hidden(true),
cue.Final(),
cue.Optional(false),
cue.Optional(true),
cue.ResolveReferences(true),
)
}
Expand Down
25 changes: 23 additions & 2 deletions lib/datamodel/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,31 @@ package datamodel

import (
"fmt"

"github.com/hofstadter-io/hof/cmd/hof/flags"
"github.com/hofstadter-io/hof/lib/cuetils"
)

func RunGetFromArgs(args []string) error {
fmt.Println("lib/datamodel.Get", args)
func RunGetFromArgs(args []string, cmdpflags flags.DatamodelPflagpole) error {
fmt.Println("lib/datamodel.Get", args, cmdpflags)

cueFiles := args

// Loadup our Cue files
crt, err := cuetils.CueRuntimeFromEntrypointsAndFlags(cueFiles)
if err != nil {
return err
}

// TODO: find values from flags / attributes
val := crt.CueValue

syn, err := cuetils.PrintCueValue(val)
if err != nil {
return err
}

fmt.Println(syn)

return nil
}

0 comments on commit b1c7ddd

Please sign in to comment.