Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ This repo is designed to produce git hook commands that take care of metadata ad

```
git clone repo
forge init -- exactly same as git-dirs init, just a wrapper around it
forge init -- exactly same as git-drs init, just a wrapper around it
git add files
git commit -m "test" -- same as git-drs
git push origin main -- same as git-dirs
git push origin main -- same as git-drs
forge publish [github personal access token]
```

Expand Down
3 changes: 3 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var RootCmd = &cobra.Command{
Short: "A powerful command-line tool for project management.",
Long: `Forge is a versatile CLI application designed to streamline various
development and project management tasks.`,
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true,
},
}

func init() {
Expand Down
29 changes: 20 additions & 9 deletions cmd/config/main.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
package config

import (
"fmt"

"github.com/calypr/forge/config"
conf "github.com/calypr/git-drs/config"
"github.com/calypr/forge/utils/remoteutil"
"github.com/spf13/cobra"
)

var (
configRemote string
)

var ConfigCmd = &cobra.Command{
Use: "config [remote]",
Use: "config",
Short: "Build skeleton template for CALYPR explorer page config.",
Long: `Used for creating a template CALYPR explorer config to build and customize your own config`,
Example: "forge config local",
Example: "forge config --remote local",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
var remote string
if len(args) > 0 {
remote = args[0]
} else {
remote = ""
remote, err := remoteutil.LoadRemoteOrDefault(configRemote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}
err := config.RunConfigInit(conf.Remote(remote))
fmt.Printf("Using remote: %s\n", string(*remote))

err = config.RunConfigInit(*remote)
if err != nil {
return err
}
return nil
},
}

func init() {
ConfigCmd.Flags().StringVarP(&configRemote, "remote", "r", "", "target DRS server (default: default_remote)")
}
29 changes: 18 additions & 11 deletions cmd/empty/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,37 @@ import (
"fmt"

"github.com/calypr/forge/publish"
"github.com/calypr/git-drs/config"
"github.com/calypr/forge/utils/remoteutil"
"github.com/spf13/cobra"
)

var (
emptyRemote string
)

var EmptyCmd = &cobra.Command{
Use: "empty <project-id> [remote]",
Use: "empty <project-id>",
Short: "empty metadata for a project",
Long: `The 'empty' command is how metadata is removed in calypr.`,
Args: cobra.RangeArgs(1, 2),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
projectID := args[0]
var remote config.Remote
if len(args) == 2 {
remote = config.Remote(args[1])
fmt.Printf("Using remote: %s\n", remote)
} else {
remote = config.Remote("")
fmt.Printf("Using default remote: %s\n", remote)

remote, err := remoteutil.LoadRemoteOrDefault(emptyRemote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}
resp, err := publish.RunEmpty(projectID, remote)
fmt.Printf("Using remote: %s\n", string(*remote))

resp, err := publish.RunEmpty(projectID, *remote)
if err != nil {
return err
}
fmt.Printf("Uid: %s\t Name: %s\t Status: %s\n", resp.Uid, resp.Name, resp.Status)
return nil
},
}

func init() {
EmptyCmd.Flags().StringVarP(&emptyRemote, "remote", "r", "", "target DRS server (default: default_remote)")
}
27 changes: 20 additions & 7 deletions cmd/meta/main.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
package meta

import (
"fmt"

"github.com/calypr/forge/metadata"
"github.com/calypr/git-drs/config"
"github.com/spf13/cobra"
)

var outPath string
var (
outPath string
remote string
)

var MetaCmd = &cobra.Command{
Use: "meta",
Short: "Autogenerate metadata based off of files that have been uploaded",
Long: `Not needed for expected user workflow. Useful for debugging server side operations only.`,
Example: "forge meta [remote]",
Example: "forge meta",
Args: cobra.RangeArgs(0, 1),
RunE: func(cmd *cobra.Command, args []string) error {
var remoteName string = "origin"
if len(args) > 0 {
remoteName = args[0]

cfg, err := config.LoadConfig()
if err != nil {
return fmt.Errorf("unable to load config: %w", err)
}

remoteName, err := cfg.GetRemoteOrDefault(remote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}

err := metadata.RunMetaInit(outPath, config.Remote(remoteName))
err = metadata.CreateMeta(outPath, remoteName)
if err != nil {
return err
return fmt.Errorf("could not create metadata: %w", err)
}
return nil
},
}

func init() {
MetaCmd.PersistentFlags().StringVarP(&outPath, "out", "o", metadata.META_DIR, "Directory path to output FHIR .ndjson files")
MetaCmd.Flags().StringVarP(&remote, "remote", "r", "", "target DRS server (default: default_remote)")
}
24 changes: 16 additions & 8 deletions cmd/ping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,27 @@ import (
"log"

"github.com/calypr/forge/client/fence"
"github.com/calypr/git-drs/config"
"github.com/calypr/forge/utils/remoteutil"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)

var (
pingRemote string
)

var PingCmd = &cobra.Command{
Use: "ping [remote]",
Use: "ping",
Short: "Ping Calypr instance and return user's project and user permissions",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
var remote config.Remote
if len(args) > 0 {
remote = config.Remote(args[0])
} else {
remote = config.Remote("origin")
remote, err := remoteutil.LoadRemoteOrDefault(pingRemote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}
fmt.Printf("Using remote: %s\n", string(*remote))

FenceClient, closer, err := fence.NewFenceClient(remote)
FenceClient, closer, err := fence.NewFenceClient(*remote)
if err != nil {
return err
}
Expand All @@ -41,3 +45,7 @@ var PingCmd = &cobra.Command{
return nil
},
}

func init() {
PingCmd.Flags().StringVarP(&pingRemote, "remote", "r", "", "target DRS server (default: default_remote)")
}
93 changes: 60 additions & 33 deletions cmd/publish/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ import (

"github.com/calypr/forge/client/sower"
"github.com/calypr/forge/publish"
"github.com/calypr/git-drs/config"
"github.com/calypr/forge/utils/remoteutil"
"github.com/spf13/cobra"
)

var (
publishRemote string
)

var PublishCmd = &cobra.Command{
Use: "publish <github_personal_access_token> [remote]",
Use: "publish <github_personal_access_token>",
Short: "create metadata upload job for FHIR ndjson files",
Long: `The 'publish' command is how metadata is handled in calypr.`,
Args: cobra.RangeArgs(1, 2),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var remote config.Remote
if len(args) == 2 {
remote = config.Remote(args[1])
fmt.Printf("Using remote: %s\n", remote)
} else {
remote = config.Remote("")
fmt.Printf("Using default remote: %s\n", remote)
remote, err := remoteutil.LoadRemoteOrDefault(publishRemote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}
resp, err := publish.RunPublish(args[0], remote)
fmt.Printf("Using remote: %s\n", string(*remote))

resp, err := publish.RunPublish(args[0], *remote)
if err != nil {
return err
}
Expand All @@ -32,18 +34,32 @@ var PublishCmd = &cobra.Command{
},
}

var (
listRemote string
)

var ListCmd = &cobra.Command{
Use: "list [remote]",
Use: "list",
Short: "view all of the jobs currently catalogued in sower",
Long: `The 'list' command is how jobs are displayed to the user`,
Args: cobra.ExactArgs(1),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
sc, closer, err := sower.NewSowerClient(config.Remote(args[0]))
remote, err := remoteutil.LoadRemoteOrDefault(listRemote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}
fmt.Printf("Using remote: %s\n", string(*remote))

sc, closer, err := sower.NewSowerClient(*remote)
if err != nil {
return err
}
defer closer()
vals, err := sc.List()
if err != nil {
return fmt.Errorf("unable to list jobs: %w", err)
}

if len(vals) == 0 {
fmt.Printf("There are no jobs to list: %s\n", vals)
} else {
Expand All @@ -55,22 +71,24 @@ var ListCmd = &cobra.Command{
},
}

var (
statusRemote string
)

var StatusCmd = &cobra.Command{
Use: "status <UID> [remote]",
Use: "status <UID>",
Short: "view the status of a specific job on sower",
Long: `The 'status' command is how sower job status is communicated to the user.
A specific job's UID can be found from running the list command`,
Args: cobra.RangeArgs(1, 2),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var remote config.Remote
if len(args) == 2 {
remote = config.Remote(args[1])
fmt.Printf("Using remote: %s\n", remote)
} else {
remote = config.Remote("")
fmt.Printf("Using default remote: %s\n", remote)
remote, err := remoteutil.LoadRemoteOrDefault(statusRemote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}
sc, closer, err := sower.NewSowerClient(remote)
fmt.Printf("Using remote: %s\n", string(*remote))

sc, closer, err := sower.NewSowerClient(*remote)
if err != nil {
return err
}
Expand All @@ -85,22 +103,24 @@ var StatusCmd = &cobra.Command{
},
}

var (
outputRemote string
)

var OutputCmd = &cobra.Command{
Use: "output <UID> [remote]",
Use: "output <UID>",
Short: "view output logs of a specific job on sower",
Long: `The 'output' command is how sower job output logs are communicated to the user.
A specific job's UID can be found from running the list command`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
var remote config.Remote
if len(args) == 2 {
remote = config.Remote(args[1])
fmt.Printf("Using remote: %s\n", remote)
} else {
remote = config.Remote("")
fmt.Printf("Using default remote: %s\n", remote)
remote, err := remoteutil.LoadRemoteOrDefault(outputRemote)
if err != nil {
return fmt.Errorf("could not locate remote: %w", err)
}
sc, closer, err := sower.NewSowerClient(remote)
fmt.Printf("Using remote: %s\n", string(*remote))

sc, closer, err := sower.NewSowerClient(*remote)
if err != nil {
return err
}
Expand All @@ -114,3 +134,10 @@ var OutputCmd = &cobra.Command{
return nil
},
}

func init() {
PublishCmd.Flags().StringVarP(&publishRemote, "remote", "r", "", "target DRS server (default: default_remote)")
ListCmd.Flags().StringVarP(&listRemote, "remote", "r", "", "target DRS server (default: default_remote)")
StatusCmd.Flags().StringVarP(&statusRemote, "remote", "r", "", "target DRS server (default: default_remote)")
OutputCmd.Flags().StringVarP(&outputRemote, "remote", "r", "", "target DRS server (default: default_remote)")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/bytedance/sonic v1.14.2
github.com/calypr/data-client v0.0.0-20251230165452-a95f44240b14
github.com/calypr/gecko v0.0.0-20251110184938-909cb1b668e2
github.com/calypr/git-drs v0.0.0-20251230165948-81a82438caa4
github.com/calypr/git-drs v0.0.0-20260105205500-0dbe7e55d1f3
github.com/cockroachdb/errors v1.11.3
github.com/go-git/go-git/v5 v5.12.0
github.com/google/fhir/go v0.7.5-0.20250925033537-1f5b5b9427ff
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ github.com/calypr/gecko v0.0.0-20251110184938-909cb1b668e2 h1:ii28j/rzbOaxpUVnON
github.com/calypr/gecko v0.0.0-20251110184938-909cb1b668e2/go.mod h1:SJfHDSOaN5xevCor2PVRZxHHJ/WwfAnBBddgnQcUwJo=
github.com/calypr/git-drs v0.0.0-20251230165948-81a82438caa4 h1:AWs5hOg6VODWhQ/S9frW+6nz476/fr/9s+nqCJRDKvA=
github.com/calypr/git-drs v0.0.0-20251230165948-81a82438caa4/go.mod h1:irPfPmQ5YCcK+GIRvjTqoU+znTL3xs8d/Ex9oX1Xriw=
github.com/calypr/git-drs v0.0.0-20260105205500-0dbe7e55d1f3 h1:xOUDTvAXwUZP/YoCDC2WCEiwjHZbnOsJFhvA5QMytAY=
github.com/calypr/git-drs v0.0.0-20260105205500-0dbe7e55d1f3/go.mod h1:2Z0yl6wUu/IeRPq0ALCakK5EnI1FntRYESEI1YbK4lg=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
Expand Down
2 changes: 1 addition & 1 deletion metadata/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type MetaStructure struct {
Path string `json:"path"`
}

func RunMetaInit(outPath string, remote config.Remote) error {
func CreateMeta(outPath string, remote config.Remote) error {
var rsID string
var err error
cfg, err := config.LoadConfig()
Expand Down
Loading