replacer

package module
v0.0.0-...-89a05df Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

replacer

Build License Go Reference Go Report Card codecov Release

The replacer is a configuration-based file replace tool.

Installation

The first need Go installed (version 1.21+ is required), then you can use the below command to install replacer.

go install github.com/no-src/replacer/...@latest
Run In Docker

You can use the build-docker.sh script to build the docker image and you should clone this repository and cd to the root path of the repository first.

$ ./scripts/build-docker.sh

Or pull the docker image directly from DockerHub with the command below.

$ docker pull nosrc/replacer

Quick Start

Create a config file named replacer.yaml, content is as follows

name: the configuration of replacer
version: v0.0.1
items:
  - name: replace domain
    paths:
      - "*/test.yaml"
    rules:
      - old:
          - 127.0.0.1:8888
          - 127.0.0.1:9999
        new:
          test: test-github.com
          uat: uat-github.com
          product: product-github.com

Now running the command below start to replace the files.

$ replacer -root="./testdata/testfile" -tag=test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Replacer

type Replacer struct {
	// contains filtered or unexported fields
}

Replacer a configuration-based file replace tool

func NewReplacer

func NewReplacer(confFile string) (*Replacer, error)

NewReplacer returns the replacer instance

func (*Replacer) Replace

func (r *Replacer) Replace(root, tag string) error

Replace start execute replace in the root workspace

func (*Replacer) Revert

func (r *Replacer) Revert(root, tag string) error

Revert try to revert the replace operation

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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