line-editor

command module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 6 Imported by: 0

README

line-editor

This is a simple edit tool for a text file. Change each line in the stream, using a javaScript snippet to rebuild these lines.

Please install Golang if you do not have Golang already installed.

  • Add GOPATH/bin to your PATH:
    • for bash: echo '\nexport PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc && source ~/.bashrc
    • for zsh: echo '\nexport PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc && source ~/.zshrc
  • Install line-editor:
    • Golang 1.16<=: go get github.com/AntonStolov/line-editor
    • Golang >=1.17: go install github.com/AntonStolov/line-editor@latest

How to use:

  • Select file using '--file' flag
  • Write javascript code to change each line from the file using '--script' flag
    • or prepare a javascript file and provide a path to this file using '--script-file' flag

Code variables

  • input - current line
  • LineBefore - line before current

Example:

Replace commas in the CSV file to the pipelines '|' if the number of rows equals 4

line-editor \
  --file test.csv \
  --script "String(input).split(',').length == 4 ? String(input).split(',').join('|') : ',,,'"

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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