cmdutil

package module
v0.0.0-...-4673ec4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 6 Imported by: 7

README

Package cloudeng.io/cmdutil

CircleCI Go Report Card

import cloudeng.io/cmdutil

Package cmdutil provides support for implementing command line utilities.

Functions

Func CopyAll
func CopyAll(fromDir, toDir string, ovewrite bool) error

CopyAll will create an exact copy, including permissions, of a local filesystem hierarchy. The arguments must both refer to directories. A trailing slash (/) for the fromDir copies the contents of fromDir rather than fromDir itself. Thus:

CopyAll("a/b", "c") is the same as CopyAll("a/b/", "c/b")
and both create an exact copy of the tree a/b rooted at c/b.

If overwrite is set any existing files will be overwritten. Existing directories will always have their contents updated. It is suitable for very large directory trees since it uses filepath.Walk.

Func CopyFile
func CopyFile(from, to string, perms os.FileMode, overwrite bool) (returnErr error)

CopyFile will copy a local file with the option to overwrite an existing file and to set the permissions on the new file. It uses chmod to explicitly set permissions. It is not suitable for very large fles.

Func Exit
func Exit(format string, args ...interface{})

Exit formats and prints the supplied parameters to os.Stderr and then calls os.Exit(1).

Func HandleSignals
func HandleSignals(fn func(), signals ...os.Signal)

HandleSignals will asynchronously invoke the supplied function when the specified signals are received.

Func IsDir
func IsDir(path string) bool

IsDir returns true iff path exists and is a directory.

Func ListDir
func ListDir(dir string) ([]string, error)

ListDir returns the lexicographically ordered directories that lie beneath dir.

Func ListRegular
func ListRegular(dir string) ([]string, error)

ListRegular returns the lexicographically ordered regular files that lie beneath dir.

Documentation

Overview

Package cmdutil provides support for implementing command line utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAll

func CopyAll(fromDir, toDir string, ovewrite bool) error

CopyAll will create an exact copy, including permissions, of a local filesystem hierarchy. The arguments must both refer to directories. A trailing slash (/) for the fromDir copies the contents of fromDir rather than fromDir itself. Thus:

CopyAll("a/b", "c") is the same as CopyAll("a/b/", "c/b")
and both create an exact copy of the tree a/b rooted at c/b.

If overwrite is set any existing files will be overwritten. Existing directories will always have their contents updated. It is suitable for very large directory trees since it uses filepath.Walk.

func CopyFile

func CopyFile(from, to string, perms os.FileMode, overwrite bool) (returnErr error)

CopyFile will copy a local file with the option to overwrite an existing file and to set the permissions on the new file. It uses chmod to explicitly set permissions. It is not suitable for very large fles.

func Exit

func Exit(format string, args ...interface{})

Exit formats and prints the supplied parameters to os.Stderr and then calls os.Exit(1).

func HandleSignals

func HandleSignals(fn func(), signals ...os.Signal)

HandleSignals will asynchronously invoke the supplied function when the specified signals are received.

func IsDir

func IsDir(path string) bool

IsDir returns true iff path exists and is a directory.

func ListDir

func ListDir(dir string) ([]string, error)

ListDir returns the lexicographically ordered directories that lie beneath dir.

func ListRegular

func ListRegular(dir string) ([]string, error)

ListRegular returns the lexicographically ordered regular files that lie beneath dir.

Types

This section is empty.

Directories

Path Synopsis
Package expect provides support for making expectations on the contents of input streams.
Package expect provides support for making expectations on the contents of input streams.
Package flags provides support for working with flag variables, and for managing flag variables by embedding them in structs.
Package flags provides support for working with flag variables, and for managing flag variables by embedding them in structs.
Package profiling provides support for enabling profiling of command line tools via flags.
Package profiling provides support for enabling profiling of command line tools via flags.
Package signals provides support for working with operating system signals and contexts.
Package signals provides support for working with operating system signals and contexts.
Package structdoc provides a means of exposing struct tags for use when generating documentation for those structs.
Package structdoc provides a means of exposing struct tags for use when generating documentation for those structs.
Package subcmd provides a multi-level command facility of the following form:
Package subcmd provides a multi-level command facility of the following form:

Jump to

Keyboard shortcuts

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