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 KittySwitchKey() keyaction.KeyAction
- func Notice(text string)
- func PathsToMounts(paths ...string) (mounts map[string]string)
- func ReadFileIntoJSON(path string, jsonStruct any) error
- func TeaFileExistsPrompt(outputFile string, followupCmd tea.Cmd) tea.Cmd
- func VideoFile(f *InputFile) error
- type Context
- type ExecuteMsg
- 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
- type InteractiveMsg
- type OutputNameModel
- type OutputNameMsg
Constants ¶
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" PathYTDLP = "yt-dlp" )
Variables ¶
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") )
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") )
var ( SectionTitleStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("#0FFFF0")). Padding(0, 1) SectionStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(lipgloss.Color("#00f000")) )
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 KittySwitchKey ¶
func PathsToMounts ¶
PathsToMounts adds active directory, prepares dirs for docker volume binding
func ReadFileIntoJSON ¶
Types ¶
type Context ¶
type Context struct {
Ctx context.Context
Cancel context.CancelFunc
// WaitGroup is used to wait for all goroutines to finish/cancel
sync.WaitGroup
}
Context is a wrapper around context.Context
type ExecuteMsg ¶
type ExecuteMsg struct{}
ExecuteMsg is a message that is sent to the model to execute the command
type Factory ¶
type Factory struct {
Logger *zap.Logger
Atom zap.AtomicLevel
// Docker wrapper a helper struct to start containers
// Deprecated: will be removed in v5.0.0
Docker docker.Wrapper
// Context is the context to be used for the command
Context *Context
// Output sets the output filename, applicable for commands with AnnotationFlagFileOutput annotation.
Output string
// Interactive starts a tui, applicable for commands with AnnotationFlagInteractive 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.
// WARN: 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 NewFactory() *Factory
func (*Factory) AddAnnotationFlags ¶
revive:disable:cognitive-complexity
func (*Factory) CleanupHandler ¶
func (f *Factory) CleanupHandler()
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
type InteractiveMsg ¶
type InteractiveMsg struct{}
InteractiveMsg is a message that is sent to the model to start the interactive mode it should only be sent once and only if the command is interactive
type OutputNameModel ¶
func NewOutputNameModel ¶
func NewOutputNameModel(name string) *OutputNameModel
func (*OutputNameModel) Init ¶
func (m *OutputNameModel) Init() tea.Cmd
func (*OutputNameModel) OutputName ¶
func (m *OutputNameModel) OutputName() string
func (*OutputNameModel) View ¶
func (m *OutputNameModel) View() string
type OutputNameMsg ¶
type OutputNameMsg string
func (*OutputNameMsg) Title ¶
func (*OutputNameMsg) Title() string