hrx

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

godoc codecov Go Report Card

hrx - human readable archiver

hrx is a command line interface for working with .hrx files, which are human readable archives, typically used in writing unit tests.

For details on the HRX file format, see: https://github.com/google/hrx

Note: this project has no affiliation with Google and is entirely independent.

Installation

> go install github.com/go-coreutils/hrx/cmd/hrx@latest

Usage

$ hrx -h
usage: hrx [global options] <-l|-c|-x> -f <archive> [pathnames...]
       hrx --help
       hrx --list -f existing.hrx
       hrx --create -f new.hrx <path> [paths...]
       hrx --extract -f existing.hrx [pathnames...]

Help

$ hrx --help
NAME:
   hrx - human-readable archive (.hrx) utility

USAGE:
   hrx [global options] <-l|-c|-x> -f <archive> [pathnames...]

VERSION:
   v0.5.x

DESCRIPTION:
   hrx is like the tar command except that the archives are human readable.

   These archives are in a plain-text, human-friendly format for defining multiple
   virtual text files in a single physical file, for situations when creating many
   physical files is undesirable, such as defining datasets for unit test cases.

   For details on the HRX file format, see: https://github.com/google/hrx

   Note: this project has no affiliation with Google and is entirely independent.

   OPERATIONS:

     There are currently three operational modes that can be performed:

       --list     (-l)
       --create   (-c)
       --extract  (-x)

     All modes require the --archive (-f) flag.

   EXAMPLES:

     # list the contents of an archive named "custom-name.hrx"
     hrx -lf custom-name.hrx

     # create a new archive named "custom-name.hrx" with all files named "files"
     # with any extension
     hrx -cf custom-name.hrx files.*

     # extract an archive named "custom-name.hrx" into a sub-directory named
     # "custom-name"
     hrx -xf custom-name.hrx


GLOBAL OPTIONS:
   --help         show detailed help
   --usage, -h    show brief usage 
   --verbose, -v  output progress 
   --version, -V  display the version

   OPERATIONS

   --create, -c   create a new archive 
   --extract, -x  extract an existing archive 
   --list, -l     list all archive entries 

   SETTINGS

   --all, -a                      include hidden files and directories 
   --archive value, -f value      specify the archive file
   --boundary value, -b value     specify the entry boundary size 
   --directory value, -o value    specify the output directory
   --keep-empty, -k               include empty files and directories 
   --prune-dir, -P                remove the top directory from all pathnames 
   --recurse, -r                  recurse into directories (default) 
   --trim-prefix value, -T value  trim given prefix from all pathnames

HRX Go Module

For pragmatically interacting with HRX archives, please use the go-corelibs/hrx module which this project is built with. The functions available within this project are intended for use within this specific command-line application.

Go-CoreUtils

Go-CoreUtils is a collection of command line utilities, mostly related to the development of the Go-Curses and Go-Enjin projects.

License

Copyright 2024 The Go-CoreUtils Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use file except in compliance with the License.
You may obtain a copy of the license at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Overview

Package hrx provides the primary functionality of the go-coreutils hrx command.

Index

Constants

View Source
const (
	OpWrote    = "wrote"
	OpListing  = "listing"
	OpArchived = "archived"
)

Variables

View Source
var (
	ErrNotRegular   = errors.New("not a regular file")
	ErrNotPlainText = errors.New("not a plain text file")
	ErrPathRequired = errors.New("at least one path is required")
	ErrFileNotFound = errors.New("file not found")
)
View Source
var (
	// Notifier is the user notice output handler
	Notifier notify.Notifier
)

Functions

func Create

func Create(opt *Options, dst string, pathnames ...string) (a hrx.Archive, err error)

Create produces an archive with the given `pathnames`, according to the Options given and writes the archive to the `dst` path

func Extract

func Extract(opt *Options, src, dst string, pathnames ...string) (err error)

Extract takes an existing `src` archive and extracts it to the `dst` directory, according to the Options given. If `pathnames` are provided, only those pathnames that exist within the `src` archive are extracted

func List

func List(src string, pathnames ...string) (err error)

List displays a list of pathnames within an existing `src` archive file. If any `pathnames` are given, List will only display those pathnames given that exist within the `src` archive file

Types

type Options

type Options struct {
	// All specifies to include hidden files and directories
	All bool
	// Recurse specifies to traverse directories recursively
	Recurse bool
	// PruneDir specifies to prune the top directory from files added to the
	// Archive
	PruneDir bool
	// Boundary specifies the Archive boundary size to use
	Boundary int
	// TrimPrefix specifies an arbitrary string prefix to trim from files
	// added to the Archive
	TrimPrefix string
	// KeepEmpty specifies to include empty directories when added to the
	// Archive
	KeepEmpty bool
}

Options are the complete configurable options for Create and Extract

Directories

Path Synopsis
cmd
hrx command

Jump to

Keyboard shortcuts

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