MCPcopy Index your code
hub / github.com/dnote/dnote / getContent

Function getContent

pkg/cli/cmd/add/add.go:77–103  ·  view source on GitHub ↗
(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

75}
76
77func getContent(ctx context.DnoteCtx) (string, error) {
78 if contentFlag != "" {
79 return contentFlag, nil
80 }
81
82 // check for piped content
83 fInfo, _ := os.Stdin.Stat()
84 if fInfo.Mode() & os.ModeCharDevice == 0 {
85 c, err := ui.ReadStdInput()
86 if err != nil {
87 return "", errors.Wrap(err, "Failed to get piped input")
88 }
89 return c, nil
90 }
91
92 fpath, err := ui.GetTmpContentPath(ctx)
93 if err != nil {
94 return "", errors.Wrap(err, "getting temporarily content file path")
95 }
96
97 c, err := ui.GetEditorInput(ctx, fpath)
98 if err != nil {
99 return "", errors.Wrap(err, "Failed to get editor input")
100 }
101
102 return c, nil
103}
104
105func newRun(ctx context.DnoteCtx) infra.RunEFunc {
106 return func(cmd *cobra.Command, args []string) error {

Callers 1

newRunFunction · 0.70

Calls 3

ReadStdInputFunction · 0.92
GetTmpContentPathFunction · 0.92
GetEditorInputFunction · 0.92

Tested by

no test coverage detected