contentmgmt

package module
v0.0.0-...-78bca33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 8 Imported by: 0

README

imgcontent

CLI tool for image content management. Register image files used for blog posts, etc. in the cloud storage.

At the time of initial development, Google Cloud Storage is targeted.

Installation

[Notice] We have not yet distributed prebuilt binaries 😴

get src and build binary with go get:

go get github.com/micheam/contentmgmt/cmd/imgcontent

imgcontent binary will be installed:

imgcontent help

Environment values

env content note
IMGCONTENT_GCS_CREDENTIALS Path to Google CloudStorage Credential file (json) $HOME/.config/imgcontent/your-bucket-999999999999.json
IMGCONTENT_GCS_BUCKET bucket name your-bucket

Usage

NAME:
   imagecontent - manage img content

USAGE:
   imgcontent [global options] command [command options] [arguments...]

VERSION:
   0.2.0

AUTHOR:
   Michto Maeda <https://github.com/micheam>

COMMANDS:
     upload   upload file as a web content
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Command: Upload

NAME:
   imgcontent upload - upload file as a web content

USAGE:
   imgcontent upload [command options] <filepath>

OPTIONS:
   --format value  Display result with specified format. [mkd,html,adoc]
   --clipboard, -c  Write result to clipboard

Upload your content to Google-CloudStorage:

imgcontent upload ./sample.jpeg

Result will print via stdout:

$ imgcontent upload ./sample.jpeg
https://storage.googleapis.com/micheam-image-content/2019/11/17/070934.image.jpg

You can specify result format with --format:

$ imgcontent upload --format mkd ./sample.jpeg
![sample.jpeg](https://storage.googleapis.com/micheam-image-content/2019/11/19/100607.sample.jpeg)

Author

micheam - https://github.com/micheam/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentPath

type ContentPath string

type ContentPathBuilder

type ContentPathBuilder interface {
	Build(ctx context.Context, filename Filename) (ContentPath, error)
}

type ContentWriter

type ContentWriter interface {
	Write(ctx context.Context, reader io.Reader, path ContentPath) (url.URL, error)
}

type ErrIllegalFilename

type ErrIllegalFilename string

func (ErrIllegalFilename) Error

func (e ErrIllegalFilename) Error() string

type Filename

type Filename struct {
	Value string
	Valid bool
}

func NewFilename

func NewFilename(raw string) (fname *Filename, err error)

type GCPContentRepository

type GCPContentRepository struct {
	BucketName string
	Client     *storage.Client
}

func (GCPContentRepository) Write

func (g GCPContentRepository) Write(ctx context.Context, file io.Reader, path ContentPath) (url url.URL, err error)

type UploadInput

type UploadInput struct {
	Filename
	Reader io.Reader
}

type UploadOutput

type UploadOutput struct {
	Filename
	url.URL
}

type UploadResultPresenter

type UploadResultPresenter interface {
	Complete(ctx context.Context, data UploadOutput) error
}

type UploadUsecase

type UploadUsecase struct {
	PathBuilder ContentPathBuilder
	Writer      ContentWriter
	Presenter   UploadResultPresenter
}

func (UploadUsecase) Handle

func (u UploadUsecase) Handle(ctx context.Context, input UploadInput) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL