fs

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: MIT Imports: 19 Imported by: 0

README

FS: File Snippet

banner

ci release go report card license go version release

FS is the file snippet CLI. FS copies the file interactively according to a custom-defined TOML file.

Install

Download from GitHub Releases.

go get github.com/skmatz/fs/...

Usage

After the installation, prepare a TOML file like the following in ~/.config/fs/fs.toml.

[config]
head_size = 10
item_size = 10

[[snippet]]
id = "gitignore-go"
name = ".gitignore"
content = """
bin/
"""

[[snippet]]
id = "gitignore-py"
name = ".gitignore"
file = "~/sandbox/python/.gitignore"

[[snippet]]
id = "license-mit"
name = "LICENSE"
url = "https://raw.githubusercontent.com/skmatz/fs/master/LICENSE"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.2.0

type Config struct {
	HeadSize int `toml:"head_size"`
	ItemSize int `toml:"item_size"`
}

Config represents the configuration of the application.

type FS

type FS struct {
	Config   Config   `toml:"config"`
	Snippets Snippets `toml:"snippet"`
}

FS represents a FS client.

func New

func New(path string) (*FS, error)

New returns a new FS client.

func (*FS) ToBytes added in v0.2.0

func (f *FS) ToBytes() ([]byte, error)

ToBytes converts itself to bytes.

type Mode added in v0.2.0

type Mode = string

Mode is the snippet mode.

const (
	ModeContent Mode = "content"
	ModeFile    Mode = "file"
	ModeURL     Mode = "url"
)

type Snippet

type Snippet struct {
	ID      string `toml:"id"`
	Name    string `toml:"name"`
	Content string `toml:"content,omitempty"`
	File    string `toml:"file,omitempty"`
	URL     string `toml:"url,omitempty"`
}

Snippet represents a snippet.

func (*Snippet) FillAllFields added in v0.2.0

func (s *Snippet) FillAllFields() error

FillAllFields fills the all fields according to the text template.

func (*Snippet) GetMode added in v0.2.0

func (s *Snippet) GetMode() (string, error)

GetMode returns the snippet mode.

func (*Snippet) ToClipboard

func (s *Snippet) ToClipboard() error

ToClipboard writes its content to the clipboard.

func (*Snippet) ToFile

func (s *Snippet) ToFile() error

ToFile writes its content to a file.

type Snippets added in v0.2.0

type Snippets []Snippet

Snippets is a list of snippets.

func (Snippets) Select added in v0.2.0

func (s Snippets) Select() (*Snippet, error)

Select selects a snippet.

Directories

Path Synopsis
cmd
fs

Jump to

Keyboard shortcuts

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