reinc

package module
v0.0.0-...-6cfa447 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

reinc

include files using RegExp

Usage

reinc -P '(?m)^@(.+?)@\n' -o out.txt in.txt

or

reinc -P '(?m)^@(.+?)@\n' - <in.txt >out.txt
Input file (in.txt)
---
@parts/index.txt@
---
Included file (parts/index.txt)
@hello.txt@
Included file (parts/hello.txt)
Hello, world!
Output file (out.txt)
---
Hello, world!
---

License

Apache License 2.0

Documentation

Index

Constants

View Source
const (
	RuleModeDefault string = ""
	RuleModeFileDir        = "filedir"
	RuleModeWorkDir        = "workdir"
)
View Source
const (
	Version = "0.1.0-beta"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Replacer

type Replacer struct {
	Writer          io.Writer
	Reader          io.Reader
	Path            string
	Rules           Rules
	MaxDepth        int
	RootDir         string
	IncludedPathSet map[string]struct{}
	// contains filtered or unexported fields
}

func NewReplacer

func NewReplacer(w io.Writer, r io.Reader) *Replacer

func NewReplacerWithConfig

func NewReplacerWithConfig(w io.Writer, r io.Reader, config *ReplacerConfig) (*Replacer, error)

func (*Replacer) Replace

func (r *Replacer) Replace() (int, error)

type ReplacerConfig

type ReplacerConfig struct {
	Rules []*RuleConfig `json:"rules"`
}

type Rule

type Rule struct {
	Regexp            *regexp.Regexp
	PathFormat        []byte
	Once              bool
	OnceFormat        []byte
	IgnoreError       bool
	IgnoreErrorFormat []byte
	Mode              string
}

func NewRule

func NewRule(config *RuleConfig) (*Rule, error)

type RuleConfig

type RuleConfig struct {
	Pattern           string `json:"pattern"`
	PathFormat        string `json:"path_format"`
	Once              bool   `json:"once"`
	OnceFormat        string `json:"once_format"`
	IgnoreError       bool   `json:"ignore_error"`
	IgnoreErrorFormat string `json:"ignore_error_format"`
	Mode              string `json:"mode"`
}

type Rules

type Rules []*Rule

Directories

Path Synopsis
cli
cmd

Jump to

Keyboard shortcuts

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