Skip to content

Commit

Permalink
redirect cli output to file
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Nov 15, 2024
1 parent 40d51ce commit c0ba92b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cmd/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ commonmeta 10.5555/12345678`,
email, _ := cmd.Flags().GetString("email")
registrant, _ := cmd.Flags().GetString("registrant")

cmd.SetOut(os.Stdout)
cmd.SetErr(os.Stderr)

if len(args) == 0 {
fmt.Println("Please provide an input")
return
Expand Down
3 changes: 3 additions & 0 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ var listCmd = &cobra.Command{
email, _ := cmd.Flags().GetString("email")
registrant, _ := cmd.Flags().GetString("registrant")

cmd.SetOut(os.Stdout)
cmd.SetErr(os.Stderr)

if input != "" {
_, err = os.Stat(input)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ commonmeta post 10.5555/12345678 -f crossref -t inveniordm -h rogue-scholar.org
host, _ := cmd.Flags().GetString("host")
token, _ := cmd.Flags().GetString("token")

cmd.SetOut(os.Stdout)
cmd.SetErr(os.Stderr)

if input != "" {
_, err = os.Stat(input)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var versionCmd = &cobra.Command{
Short: "Print the version number of commonmeta",
Long: `All software has versions. This is commonmeta's`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Println("Commonmeta v0.5.22 -- HEAD")
cmd.Println("Commonmeta v0.5.23 -- HEAD")
},
}

Expand Down
8 changes: 4 additions & 4 deletions inveniordm/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,19 @@ func PostAll(list []commonmeta.Data, host string, apiKey string) ([]byte, error)
// workaround until JSON schema validation is implemented
// check for required fields
if inveniordm.Metadata.Title == "" {
fmt.Println("Title is required: ", data.ID)
// fmt.Println("Title is required: ", data.ID)
continue
}
if inveniordm.Metadata.ResourceType.ID == "" {
fmt.Println("ResourceType is required: ", data.ID)
// fmt.Println("ResourceType is required: ", data.ID)
continue
}
if inveniordm.Metadata.PublicationDate == "" {
fmt.Println("PublicationDate is required: ", data.ID)
// fmt.Println("PublicationDate is required: ", data.ID)
continue
}
if len(inveniordm.Metadata.Creators) == 0 {
fmt.Println("Creators is required: ", data.ID)
// fmt.Println("Creators is required: ", data.ID)
continue
}

Expand Down

0 comments on commit c0ba92b

Please sign in to comment.