Documentation ¶
Index ¶
- Constants
- Variables
- func AddGroup(parent *cobra.Command, title string, cmds ...*cobra.Command)
- func AudioFile(f *InputFile) error
- func BindInputFile(f *InputFile, path string) error
- func CanonicalizePaths(paths ...*string) error
- func CreateFolder(path string) error
- func DockerfyCommand(cmd *cobra.Command, args []string) []string
- func ImageFile(f *InputFile) error
- func IsFileAudio(filepath string) (bool, error)
- func IsFileAudioOrVideo(filepath string) (isAudio, isVideo bool, err error)
- func IsFileImage(filepath string) (bool, error)
- func IsFileVideo(filepath string) (bool, error)
- func PathsToMounts(paths ...string) (mounts map[string]string)
- func ReadFileIntoJSON(path string, jsonStruct any) error
- func VideoFile(f *InputFile) error
- type Factory
- type InputFile
- func (f *InputFile) Canonicalize() error
- func (f *InputFile) IsAudio() bool
- func (f *InputFile) IsImage() bool
- func (f *InputFile) IsVideo() bool
- func (f *InputFile) ReadFile() ([]byte, error)
- func (f *InputFile) Set(path string) error
- func (f *InputFile) String() string
- func (*InputFile) Type() string
- func (f *InputFile) ValidateAnd() error
- func (f *InputFile) ValidateOr() error
- type InputFileConstrains
Constants ¶
View Source
const ( AnnotationFlagDocker = "flag-docker" AnnotationFlagInteractive = "flag-interactive" AnnotationFlagFileConstrains = "flag-file-validations" AnnotationFlagFileOutput = "flag-file-output" FlagDocker = "docker" FlagDaemon = "daemon" FlagInteractive = "interactive" FlagFileConstrains = "ignore-file-validations" FlagValidations = "ignore-validations" FlagFileOutput = "output" // Path annotations should check against the given cmd exists in $PATH, else // throw an error. PathFfmpeg = "ffmpeg" PathFfprobe = "ffprobe" )
Variables ¶
View Source
var ( ErrorMultiCommandDaemon = errors.New("cannot run command as daemon on host machine, you can use --docker with --daemon") ErrorInteractiveCommandDaemon = errors.New("cannot run interactive command as daemon") )
View Source
var ( ErrorNotVideoFile = errors.New("file provided is not in a video format, can be suppressed with --ignore-file-validations flag") ErrorNotImageFile = errors.New("file provided is not in an image format, can be suppressed with --ignore-file-validations flag") ErrorNotAudioFile = errors.New("file provided is not in an audio format, can be suppressed with --ignore-file-validations flag") ErrorNotAcceptedFile = errors.New("file provided is not in an acceptable format, can be suppressed with --ignore-file-validations flag") ErrorFileDoesNotExist = errors.New("file does not exist") )
View Source
var ( DockerImage string DockerLabels = map[string]string{"creator": "godl"} )
Functions ¶
func BindInputFile ¶
func CanonicalizePaths ¶
CanonicalizePaths updates each path to it's full system path. Deprecated: use InputFile
func CreateFolder ¶
CreateFolder Checks if folder exists and if it doesn't it creates it.
func DockerfyCommand ¶
DockerfyCommand returns a slice with all parts of the invoked command
func IsFileAudio ¶
func IsFileAudioOrVideo ¶
func IsFileImage ¶
func IsFileVideo ¶
func PathsToMounts ¶
PathsToMounts adds active directory, prepares dirs for docker volume binding
func ReadFileIntoJSON ¶
Types ¶
type Factory ¶
type Factory struct { Logger *zap.Logger // Docker wrapper a helper struct to start containers // Deprecated: will be removed in v5.0.0 Docker docker.Wrapper // Output sets the output filename, applicable for commands with "flag-output" annotation. Output string // Interactive starts a tui, applicable for commands with "flag-interactive" annotation. Interactive bool // ExecuteInDocker run the command inside docker ExecuteInDocker bool // IgnoreValidations run the command without performing any validations IgnoreValidations bool // IgnoreFileConstrains run the command without performing any InputFile validations IgnoreFileConstrains bool // Daemon run the command in daemon. This can cause an orphaned process if the command expects any user input. Daemon bool // Debug set the Logger level to debug mode Debug bool // InsideDocker states if the command is currently running inside docker. InsideDocker bool }
func NewFactory ¶
func (*Factory) AddAnnotationFlags ¶
revive:disable:cognitive-complexity
func (*Factory) ListenForCancelSignals ¶
func (f *Factory) ListenForCancelSignals(cancel context.CancelFunc)
type InputFile ¶
type InputFile struct { // Name of the file including Ext Name string // BaseName name of the file without Ext BaseName string // Ext of the file including "." Ext string // Path to the file Path string IgnoreConstraints bool // contains filtered or unexported fields }
func NewInputFile ¶
func NewInputFile(constraints ...InputFileConstrains) *InputFile
func (*InputFile) Canonicalize ¶
Canonicalize gets the absolute system path of the current InputFile.
func (*InputFile) ValidateAnd ¶
ValidateAnd checks the file against all constrains, if any of them fail, return an error
func (*InputFile) ValidateOr ¶
ValidateOr checks the file until one constrain passes, if none do, return an error
type InputFileConstrains ¶
InputFileConstrains are constrains run against the file
Source Files ¶
Click to show internal directories.
Click to hide internal directories.