Documentation ¶
Overview ¶
Package docbasecli は、CLI向けの各種機能を提供します
Index ¶
- Constants
- Variables
- func CaptureInputFromEditor(resolveEditor PreferredEditorResolver, file *os.File) ([]byte, error)
- func CreatePost(ctx context.Context, req CreatePostRequest, handler PostHandler) error
- func GetPost(ctx context.Context, req GetPostRequest, handle PostHandler) error
- func GetPreferredEditorFromEnvironment() string
- func IsTerminal(f *os.File) bool
- func ListPosts(ctx context.Context, req ListPostsRequest, handle PostCollectionHandler) error
- func ListTags(ctx context.Context, req ListTagsRequest, presenter TagCollectionPresenter) error
- func OpenBrowser(_ context.Context, post docbase.Post) error
- func OpenFileInEditor(filename string, resolveEditor PreferredEditorResolver) error
- func UpatePost(ctx context.Context, req UpdatePostRequest, handle PostHandler) error
- type Config
- type ConfigMap
- type CreatePostRequest
- type GetPostRequest
- type ListPostsRequest
- type ListTagsRequest
- type PostCollectionHandler
- type PostHandler
- type PreferredEditorResolver
- type TagCollectionPresenter
- type UpdatePostRequest
Constants ¶
const DefaultEditor = "vim"
DefaultEditor is vim because we're adults ;)
Variables ¶
var DefaultPostOption = docbase.PostOption{ Draft: pointer.BoolPtr(true), Tags: []string{}, Scope: "private", Groups: []int{}, }
DefaultPostOption メモ作成時のデフォルトオプション
var ErrNotFound = errors.New("no post found")
Functions ¶
func CaptureInputFromEditor ¶
func CaptureInputFromEditor(resolveEditor PreferredEditorResolver, file *os.File) ([]byte, error)
CaptureInputFromEditor opens a temporary file in a text editor and returns the written bytes on success or an error on failure. It handles deletion of the temporary file behind the scenes.
func CreatePost ¶
func CreatePost(ctx context.Context, req CreatePostRequest, handler PostHandler) error
func GetPost ¶
func GetPost(ctx context.Context, req GetPostRequest, handle PostHandler) error
func GetPreferredEditorFromEnvironment ¶
func GetPreferredEditorFromEnvironment() string
GetPreferredEditorFromEnvironment returns the user's editor as defined by the `$EDITOR` environment variable, or the `DefaultEditor` if it is not set.
func IsTerminal ¶
func ListPosts ¶
func ListPosts(ctx context.Context, req ListPostsRequest, handle PostCollectionHandler) error
func ListTags ¶
func ListTags(ctx context.Context, req ListTagsRequest, presenter TagCollectionPresenter) error
func OpenBrowser ¶
func OpenFileInEditor ¶
func OpenFileInEditor(filename string, resolveEditor PreferredEditorResolver) error
OpenFileInEditor opens filename in a text editor.
func UpatePost ¶
func UpatePost(ctx context.Context, req UpdatePostRequest, handle PostHandler) error
Types ¶
type CreatePostRequest ¶
type GetPostRequest ¶
type GetPostRequest struct { ID docbase.PostID Domain string }
type ListPostsRequest ¶
type ListTagsRequest ¶
type ListTagsRequest struct {
Domain string
}
type PostCollectionHandler ¶
define ResultHandlers
func BuildPostCollectionHandler ¶
func BuildPostCollectionHandler(withMeta bool) (PostCollectionHandler, error)
type PostHandler ¶
define ResultHandlers
func OutputPostBody ¶
func OutputPostBody(out io.Writer) PostHandler
func OutputPostDetail ¶
func OutputPostDetail(out io.Writer, n int) PostHandler
type PreferredEditorResolver ¶
type PreferredEditorResolver func() string
PreferredEditorResolver is a function that returns an editor that the user prefers to use, such as the configured `$EDITOR` environment variable.