command

package module
v0.1.4 Latest Latest
Warning

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

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

README

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dirname

func Dirname(_ ...any) gloo.Command[[]byte, []byte]

Dirname returns a Command that strips the final component from each input path, equivalent to the Unix dirname(1) utility.

It matches GNU dirname's pure string semantics: trailing separators are removed, the last component is dropped, and remaining trailing separators are removed. Interior separators are preserved and "." / ".." are not resolved, so "a//b//c" yields "a//b" and "/foo/.." yields "/foo".

Example
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

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

func main() {
	lines, _ := testable.TestLines(command.Dirname(), "/usr/local/bin/script.sh\n/var/log/app.log\n")
	for _, line := range lines {
		fmt.Println(line)
	}
}
Output:
/usr/local/bin
/var/log
Example (FilenameOnly)
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

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

func main() {
	lines, _ := testable.TestLines(command.Dirname(), "filename\n")
	for _, line := range lines {
		fmt.Println(line)
	}
}
Output:
.

Types

This section is empty.

Directories

Path Synopsis
Package alias provides an unprefixed name for the dirname command.
Package alias provides an unprefixed name for the dirname command.

Jump to

Keyboard shortcuts

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