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
34 changes: 14 additions & 20 deletions cmd/approval.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"
"strings"
"text/tabwriter"

"github.com/pepabo/xpoint-cli/internal/xpoint"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -139,16 +138,14 @@ func runApprovalList(cmd *cobra.Command, args []string) error {
}

return render(res, resolveOutputFormat(approvalListOutput), approvalListJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintf(os.Stdout, "total: %d\n", res.TotalCount)
fmt.Fprintln(w, "DOCID\tSTATUS\tFORM_NAME\tAPPLY_USER\tAPPROVERS\tAPPLY_DATETIME\tTITLE1")
w := newTable(os.Stdout,
"DOCID", "STATUS", "FORM_NAME", "APPLY_USER", "APPROVERS", "APPLY_DATETIME", "TITLE1")
for _, a := range res.ApprovalList {
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%s\t%s\t%s\n",
a.DocID, a.DisplayStatus, a.FormName, a.ApplyUser,
strings.Join(a.ApprovalUser, ","), a.ApplyDatetime, a.Title1,
)
w.AddRow(a.DocID, a.DisplayStatus, a.FormName, a.ApplyUser,
strings.Join(a.ApprovalUser, ","), a.ApplyDatetime, a.Title1)
}
w.Print()
return nil
})
}
Expand Down Expand Up @@ -179,22 +176,20 @@ func runApprovalWait(cmd *cobra.Command, args []string) error {
}

return render(res, resolveOutputFormat(approvalWaitOutput), approvalWaitJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "TYPE\tNAME\tCOUNT")
w := newTable(os.Stdout, "TYPE", "NAME", "COUNT")
for _, s := range res.StatusList {
fmt.Fprintf(w, "%d\t%s\t%d\n", s.Type, s.Name, s.Count)
w.AddRow(s.Type, s.Name, s.Count)
}
w.Flush()
w.Print()

if len(res.WaitList) > 0 {
fmt.Fprintln(os.Stdout)
fmt.Fprintln(os.Stdout, "最新の承認待ち書類:")
w2 := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w2, "DOCID\tFORM_NAME\tWRITER\tWRITE_DATE\tTITLE")
w2 := newTable(os.Stdout, "DOCID", "FORM_NAME", "WRITER", "WRITE_DATE", "TITLE")
for _, d := range res.WaitList {
fmt.Fprintf(w2, "%d\t%s\t%s\t%s\t%s\n", d.DocID, d.Name, d.WriterName, d.WriteDate, d.Title)
w2.AddRow(d.DocID, d.Name, d.WriterName, d.WriteDate, d.Title)
}
w2.Flush()
w2.Print()
}
return nil
})
Expand Down Expand Up @@ -228,12 +223,11 @@ func runApprovalHidden(cmd *cobra.Command, args []string) error {

return render(res, resolveOutputFormat(approvalHiddenOutput), approvalHiddenJQ, func() error {
fmt.Fprintf(os.Stdout, "message: %s\n", res.Message)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "DOCID")
w := newTable(os.Stdout, "DOCID")
for _, id := range res.DocID {
fmt.Fprintf(w, "%d\n", id)
w.AddRow(id)
}
w.Print()
return nil
})
}
60 changes: 25 additions & 35 deletions cmd/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"path/filepath"
"strconv"
"strings"
"text/tabwriter"
"time"

"github.com/pepabo/xpoint-cli/internal/xpoint"
Expand Down Expand Up @@ -487,15 +486,13 @@ func runDocumentSearch(cmd *cobra.Command, args []string) error {
}

return render(res, resolveOutputFormat(docSearchOutput), docSearchJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintf(os.Stdout, "total: %d\n", res.TotalCount)
fmt.Fprintln(w, "DOCID\tFORM_NAME\tWRITER\tWRITE_DATETIME\tSTEP\tSTAT\tTITLE1")
w := newTable(os.Stdout,
"DOCID", "FORM_NAME", "WRITER", "WRITE_DATETIME", "STEP", "STAT", "TITLE1")
for _, it := range res.Items {
fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%d\t%d\t%s\n",
it.DocID, it.Form.Name, it.Writer, it.WriteDatetime, it.Step, it.Stat, it.Title1,
)
w.AddRow(it.DocID, it.Form.Name, it.Writer, it.WriteDatetime, it.Step, it.Stat, it.Title1)
}
w.Print()
return nil
})
}
Expand Down Expand Up @@ -534,10 +531,9 @@ func runDocumentCreate(cmd *cobra.Command, args []string) error {
}

return render(&view, resolveOutputFormat(docCreateOutput), docCreateJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "DOCID\tMESSAGE_TYPE\tMESSAGE\tURL")
fmt.Fprintf(w, "%d\t%d\t%s\t%s\n", view.DocID, view.MessageType, view.Message, view.URL)
w := newTable(os.Stdout, "DOCID", "MESSAGE_TYPE", "MESSAGE", "URL")
w.AddRow(view.DocID, view.MessageType, view.Message, view.URL)
w.Print()
return nil
})
}
Expand Down Expand Up @@ -586,10 +582,9 @@ func runDocumentEdit(cmd *cobra.Command, args []string) error {
}

return render(res, resolveOutputFormat(docEditOutput), docEditJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "DOCID\tMESSAGE_TYPE\tMESSAGE")
fmt.Fprintf(w, "%d\t%d\t%s\n", res.DocID, res.MessageType, res.Message)
w := newTable(os.Stdout, "DOCID", "MESSAGE_TYPE", "MESSAGE")
w.AddRow(res.DocID, res.MessageType, res.Message)
w.Print()
return nil
})
}
Expand All @@ -615,10 +610,9 @@ func runDocumentDelete(cmd *cobra.Command, args []string) error {
}

return render(res, resolveOutputFormat(docDeleteOutput), docDeleteJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "MESSAGE_TYPE\tMESSAGE")
fmt.Fprintf(w, "%d\t%s\n", res.MessageType, res.Message)
w := newTable(os.Stdout, "MESSAGE_TYPE", "MESSAGE")
w.AddRow(res.MessageType, res.Message)
w.Print()
return nil
})
}
Expand Down Expand Up @@ -916,10 +910,9 @@ func runDocumentCommentAdd(cmd *cobra.Command, args []string) error {
return err
}
return render(res, resolveOutputFormat(docCommentAddOutput), docCommentAddJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "DOCID\tSEQ\tMESSAGE_TYPE\tMESSAGE")
fmt.Fprintf(w, "%d\t%d\t%d\t%s\n", res.DocID, res.Seq, res.MessageType, res.Message)
w := newTable(os.Stdout, "DOCID", "SEQ", "MESSAGE_TYPE", "MESSAGE")
w.AddRow(res.DocID, res.Seq, res.MessageType, res.Message)
w.Print()
return nil
})
}
Expand All @@ -938,16 +931,15 @@ func runDocumentCommentGet(cmd *cobra.Command, args []string) error {
return err
}
return render(res, resolveOutputFormat(docCommentGetOutput), docCommentGetJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "SEQ\tATTENTION\tWRITER\tWRITE_DATE\tCONTENT")
w := newTable(os.Stdout, "SEQ", "ATTENTION", "WRITER", "WRITE_DATE", "CONTENT")
for _, cm := range res.CommentList {
attention := "-"
if cm.AttentionFlg {
attention = "*"
}
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", cm.SeqNo, attention, cm.WriterName, cm.WriteDate, cm.Content)
w.AddRow(cm.SeqNo, attention, cm.WriterName, cm.WriteDate, cm.Content)
}
w.Print()
return nil
})
}
Expand Down Expand Up @@ -990,10 +982,9 @@ func runDocumentCommentEdit(cmd *cobra.Command, args []string) error {
return err
}
return render(res, resolveOutputFormat(docCommentEditOutput), docCommentEditJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "DOCID\tSEQ\tMESSAGE_TYPE\tMESSAGE")
fmt.Fprintf(w, "%d\t%d\t%d\t%s\n", res.DocID, res.Seq, res.MessageType, res.Message)
w := newTable(os.Stdout, "DOCID", "SEQ", "MESSAGE_TYPE", "MESSAGE")
w.AddRow(res.DocID, res.Seq, res.MessageType, res.Message)
w.Print()
return nil
})
}
Expand All @@ -1019,10 +1010,9 @@ func runDocumentCommentDelete(cmd *cobra.Command, args []string) error {
return err
}
return render(res, resolveOutputFormat(docCommentDeleteOutput), docCommentDeleteJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "DOCID\tSEQ\tMESSAGE_TYPE\tMESSAGE")
fmt.Fprintf(w, "%d\t%d\t%d\t%s\n", res.DocID, res.Seq, res.MessageType, res.Message)
w := newTable(os.Stdout, "DOCID", "SEQ", "MESSAGE_TYPE", "MESSAGE")
w.AddRow(res.DocID, res.Seq, res.MessageType, res.Message)
w.Print()
return nil
})
}
Expand Down
15 changes: 6 additions & 9 deletions cmd/document_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"strconv"
"strings"
"text/tabwriter"

"github.com/pepabo/xpoint-cli/internal/xpoint"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -219,12 +218,11 @@ func runDocumentAttachmentList(cmd *cobra.Command, args []string) error {
return err
}
return render(res, resolveOutputFormat(docAttachListOutput), docAttachListJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "SEQ\tNAME\tSIZE\tCONTENT_TYPE\tREMARKS")
w := newTable(os.Stdout, "SEQ", "NAME", "SIZE", "CONTENT_TYPE", "REMARKS")
for _, a := range res.Attachments {
fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\n", a.Seq, a.Name, a.Size, a.ContentType, a.Remarks)
w.AddRow(a.Seq, a.Name, a.Size, a.ContentType, a.Remarks)
}
w.Print()
return nil
})
}
Expand Down Expand Up @@ -338,10 +336,9 @@ func runDocumentAttachmentDelete(cmd *cobra.Command, args []string) error {
}

func renderAttachmentMutation(res *xpoint.AttachmentMutationResponse) error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "DOCID\tSEQ\tMESSAGE_TYPE\tMESSAGE\tDETAIL")
fmt.Fprintf(w, "%d\t%d\t%d\t%s\t%s\n", res.DocID, res.Seq, res.MessageType, res.Message, res.Detail)
w := newTable(os.Stdout, "DOCID", "SEQ", "MESSAGE_TYPE", "MESSAGE", "DETAIL")
w.AddRow(res.DocID, res.Seq, res.MessageType, res.Message, res.Detail)
w.Print()
return nil
}

Expand Down
19 changes: 7 additions & 12 deletions cmd/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"os"
"strconv"
"text/tabwriter"

"github.com/pepabo/xpoint-cli/internal/xpoint"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -65,18 +64,17 @@ func runFormList(cmd *cobra.Command, args []string) error {
}

return render(res, resolveOutputFormat(formListOutput), formListJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "GROUP_ID\tGROUP_NAME\tFORM_ID\tFORM_CODE\tFORM_NAME")
w := newTable(os.Stdout, "GROUP_ID", "GROUP_NAME", "FORM_ID", "FORM_CODE", "FORM_NAME")
for _, g := range res.FormGroup {
if len(g.Form) == 0 {
fmt.Fprintf(w, "%d\t%s\t-\t-\t-\n", g.ID, g.Name)
w.AddRow(g.ID, g.Name, "-", "-", "-")
continue
}
for _, f := range g.Form {
fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\n", g.ID, g.Name, f.ID, f.Code, f.Name)
w.AddRow(g.ID, g.Name, f.ID, f.Code, f.Name)
}
}
w.Print()
return nil
})
}
Expand All @@ -100,16 +98,13 @@ func runFormShow(cmd *cobra.Command, args []string) error {
return render(res, resolveOutputFormat(formShowOutput), formShowJQ, func() error {
form := res.Form
fmt.Fprintf(os.Stdout, "FORM: %s %s MAX_STEP: %d\n", form.Code, form.Name, form.MaxStep)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, "PAGE\tFIELD_ID\tTYPE\tREQUIRED\tUNIQUE\tARRAYSIZE\tLABEL")
w := newTable(os.Stdout, "PAGE", "FIELD_ID", "TYPE", "REQUIRED", "UNIQUE", "ARRAYSIZE", "LABEL")
for _, p := range form.Pages {
for _, f := range p.Fields {
fmt.Fprintf(w, "%d\t%s\t%d\t%t\t%t\t%d\t%s\n",
p.PageNo, f.FieldID, f.FieldType, f.Required, f.Unique, f.ArraySize, f.Label,
)
w.AddRow(p.PageNo, f.FieldID, f.FieldType, f.Required, f.Unique, f.ArraySize, f.Label)
}
}
w.Print()
return nil
})
}
Expand Down
13 changes: 6 additions & 7 deletions cmd/me.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"fmt"
"os"
"text/tabwriter"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -48,12 +47,12 @@ func runMe(cmd *cobra.Command, args []string) error {
}

return render(info, resolveOutputFormat(meOutput), meJQ, func() error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer w.Flush()
fmt.Fprintf(w, "user_code:\t%s\n", info.AtledExt.UserCode)
fmt.Fprintf(w, "user_name:\t%s\n", info.UserName)
fmt.Fprintf(w, "display_name:\t%s\n", info.DisplayName)
fmt.Fprintf(w, "scim_id:\t%s\n", info.ID)
w := newList(os.Stdout)
w.AddRow("user_code:", info.AtledExt.UserCode)
w.AddRow("user_name:", info.UserName)
w.AddRow("display_name:", info.DisplayName)
w.AddRow("scim_id:", info.ID)
w.Print()
return nil
})
}
Loading