kuu

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 8 Imported by: 0

README

kuu

CI

Remove blank lines from the beginning and end of the file. Also, make duplicate blank lines into one.

Installation

brew install winebarrel/kuu/kuu

Usage

Usage: kuu [<files> ...] [flags]

Arguments:
  [<files> ...]    Input files.

Flags:
  -h, --help                     Show help.
  -i, --inplace                  Edit files in place.
  -b, --inplace-backup=STRING    Edit files in place (makes backup with specified suffix).
  -u, --unique                   Make duplicate blank lines unique.
      --version
$ echo -e "\n1\n2\n\n3\n"

1
2

3

$ echo -e "\n1\n2\n\n3\n" | ./kuu
1
2

3
$ (echo '---' ; cat london-bridge.txt ; echo '---') | nl -b a
     1	---
     2
     3
     4	London Bridge is broken down,
     5	Broken down, broken down.
     6
     7	London Bridge is broken down,
     8
     9
    10	My fair lady.
    11
    12
    13	---
$ kuu london-bridge.txt # or `cat london-bridge.txt | kuu`
London Bridge is broken down,
Broken down, broken down.

London Bridge is broken down,


My fair lady.
$ kuu -i london-bridge.txt # when backing up `kuu -b.bak london-bridge.txt`
$ (echo '---' ; cat london-bridge.txt ; echo '---') | nl -b a
     1	---
     2	London Bridge is broken down,
     3	Broken down, broken down.
     4
     5	London Bridge is broken down,
     6
     7
     8	My fair lady.
     9	---
Make duplicate blank lines unique

To make duplicate blank lines unique, use the -u option.

$ cat london-bridge.txt | nl -ba
     1
     2
     3		London Bridge is broken down,
     4		Broken down, broken down.
     5
     6		London Bridge is broken down,
     7
     8
     9		My fair lady.
    10
$ cat london-bridge.txt | ./kuu | nl -ba
     1		London Bridge is broken down,
     2		Broken down, broken down.
     3
     4		London Bridge is broken down,
     5
     6
     7		My fair lady.
$ cat london-bridge.txt | ./kuu -u | nl -ba
     1		London Bridge is broken down,
     2		Broken down, broken down.
     3
     4		London Bridge is broken down,
     5
     6		My fair lady.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(files []string, options *Options) error

func FilterFile

func FilterFile(tf *TargetFile, unique bool) error

Types

type Options

type Options struct {
	Inplace       bool   `kong:"short='i',xor='inplace,inplace-backup',help='Edit files in place.'"`
	InplaceBackup string `kong:"short='b',xor='inplace,inplace-backup',help='Edit files in place (makes backup with specified suffix).'"`
	Unique        bool   `kong:"short='u',help='Make duplicate blank lines unique.'"`
}

type TargetFile

type TargetFile struct {
	Fname   string
	Inplace bool
	Backup  string
}

func NewTargetFile

func NewTargetFile(fname string, inplace bool, backupSuffix string) *TargetFile

func (*TargetFile) Filter

func (tf *TargetFile) Filter(proc func(*ioutil.Scanner, io.Writer) error) error

Directories

Path Synopsis
cmd
kuu
internal

Jump to

Keyboard shortcuts

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