command

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 2 Imported by: 0

README

Documentation

Index

Examples

Constants

View Source
const (
	PasteSerial   pasteSerialFlag = true
	PasteNoSerial pasteSerialFlag = false
)

Variables

This section is empty.

Functions

func Paste

func Paste(opts ...any) gloo.Command[[]byte, []byte]

Paste merges input lines according to GNU paste semantics.

Flags:

  • PasteSerial (-s): join every line of the stream into a single row.
  • PasteDelimiter (-d): set the delimiter list cycled between joins.

In serial mode the whole stream collapses to one row whose lines are joined by the delimiter list (cycled byte by byte). In the default (parallel) mode a single input stream passes through unchanged: each line is its own row.

Example
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

	command "github.com/gloo-foo/cmd-paste"
)

func main() {
	// Default (parallel) mode: each line of a single stream is its own row.
	output, _ := testable.Test(command.Paste(), "alpha\nbeta\ngamma\n")
	fmt.Print(output)
}
Output:
alpha
beta
gamma
Example (Serial)
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

	command "github.com/gloo-foo/cmd-paste"
)

func main() {
	// Serial mode (-s) joins every line into one tab-separated row.
	output, _ := testable.Test(command.Paste(command.PasteSerial), "alpha\nbeta\ngamma\n")
	fmt.Print(output)
}
Output:
alpha	beta	gamma
Example (SerialDelimiter)
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

	command "github.com/gloo-foo/cmd-paste"
)

func main() {
	// Serial mode with a delimiter list cycled between joins.
	output, _ := testable.Test(command.Paste(command.PasteSerial, command.PasteDelimiter(",;")), "a\nb\nc\nd\n")
	fmt.Print(output)
}
Output:
a,b;c,d

Types

type PasteDelimiter

type PasteDelimiter string

PasteDelimiter is the delimiter list joined between consecutive lines (-d). GNU paste treats the argument as a list of single-byte delimiters cycled in order between joins; a single-character value behaves as one fixed separator.

Directories

Path Synopsis
Package alias provides unprefixed names for paste command flags.
Package alias provides unprefixed names for paste command flags.

Jump to

Keyboard shortcuts

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