Documentation
¶
Index ¶
- Constants
- Variables
- func DirExists(path string) bool
- func DownloadExecutable(url, destPath string) error
- func DownloadFile(url, destPath string) error
- func EnsureDir(path string) error
- func FileExists(path string) bool
- func FixPermissions(path string, filePerm, dirPerm os.FileMode) error
- func FixPermissionsDefault(path string) error
- func FormatBytes(bytes int64) string
- func GetDependenciesFromScript(scriptPath string) ([]string, error)
- func GetInteractivePromptsFromScript(scriptPath string) ([]string, error)
- func IsApptainerImage(path string) bool
- func IsImg(path string) bool
- func IsInteractiveShell() bool
- func IsOverlay(path string) bool
- func IsSif(path string) bool
- func IsSqf(path string) bool
- func IsYaml(path string) bool
- func NormalizeNameVersion(nameVersion string) string
- func ParseDuration(s string) (time.Duration, error)
- func ParseSizeToMB(sizeStr string) (int, error)
- func PrintDebug(format string, a ...interface{})
- func PrintError(format string, a ...interface{})
- func PrintHint(format string, a ...interface{})
- func PrintMessage(format string, a ...interface{})
- func PrintNote(format string, a ...interface{})
- func PrintSuccess(format string, a ...interface{})
- func PrintWarning(format string, a ...interface{})
- func ShareToUGORecursive(path string) error
- func ShouldAnswerYes() bool
- func StyleAction(act string) string
- func StyleCommand(cmd string) string
- func StyleDebug(msg string) string
- func StyleError(msg string) string
- func StyleHighlight(text string) string
- func StyleHint(msg string) string
- func StyleInfo(msg string) string
- func StyleName(name string) string
- func StyleNote(msg string) string
- func StyleNumber(num interface{}) string
- func StylePath(path string) string
- func StyleSuccess(msg string) string
- func StyleTitle(title string) string
- func StyleWarning(msg string) string
- func URLExists(url string) bool
Constants ¶
const PermDir os.FileMode = 0775
Dir: u=rwx, g=rwx, o=rx (Requires +x to traverse)
const PermExec os.FileMode = 0775
Exec: u=rwx, g=rwx, o=rx (Executable files with group write access)
const PermFile os.FileMode = 0664
Standard default permissions File: u=rw, g=rw, o=r
Variables ¶
var DebugMode = false
DebugMode controls whether PrintDebug output is visible.
var QuietMode = false
QuietMode controls whether verbose messages are suppressed (errors/warnings still shown)
var YesMode = false
YesMode controls whether to automatically answer yes to all prompts
Functions ¶
func DownloadExecutable ¶
DownloadExecutable downloads a file and sets it as executable (PermExec).
func DownloadFile ¶
DownloadFile downloads a file from url to destPath.
func FileExists ¶
FileExists checks if a file exists and is not a directory.
func FixPermissions ¶
FixPermissions automatically adjusts permissions for a path using the provided modes. If 'path' is a file, it sets it to 'filePerm'. If 'path' is a directory, it recursively sets files to 'filePerm' and subdirs to 'dirPerm'.
func FixPermissionsDefault ¶
FixPermissionsDefault is a helper that applies standard permissions (0664/0775). It is a shorthand for FixPermissions(path, PermFile, PermDir).
func FormatBytes ¶
FormatBytes formats bytes into human-readable format (e.g., "1.50 GB").
func GetDependenciesFromScript ¶
GetDependenciesFromScript parses a build script and extracts dependencies from #DEP: comments and module load commands. Returns a list of normalized dependency names with duplicates removed.
func GetInteractivePromptsFromScript ¶
GetInteractivePromptsFromScript parses a build script and extracts interactive prompt lines beginning with "#INTERACTIVE:". Returns a list of prompt strings (without the prefix) or an error if the file cannot be read.
func IsApptainerImage ¶
IsApptainerImage checks if the file matches any supported Apptainer image format. Returns true for .sif, .img, .sqf, .sqsh, .squashfs.
func IsImg ¶
IsImg checks if the path has an ext3 overlay extension (.img). Note: In Apptainer context, .img usually implies a writable ext3 overlay.
func IsInteractiveShell ¶
func IsInteractiveShell() bool
IsInteractiveShell checks if stdout is connected to a TTY (interactive terminal). Returns true if the program is running in an interactive shell, false otherwise.
func IsOverlay ¶
IsOverlay checks if the path is an overlay file (.img, .sqf, .sqsh, .squashfs). This is used for CondaTainer overlay detection.
func IsSif ¶
IsSif checks if the path has a Singularity Image Format extension (.sif). This is the native format for Apptainer/Singularity.
func IsSqf ¶
IsSqf checks if the path has a SquashFS extension (.sqf, .sqsh, .squashfs). These are read-only compressed images.
func IsYaml ¶
IsYaml checks if the path has a YAML extension (.yaml, .yml). Useful for Conda environment definition files.
func NormalizeNameVersion ¶
NormalizeNameVersion normalizes package spec formats so that "name/version", "name=version", "name@version" are treated the same. Converts = and @ to /, and -- to /, then strips whitespace.
func ParseDuration ¶
ParseDuration parses a duration string supporting multiple formats:
- Go duration: "2h", "30m", "1h30m", "90s"
- HH:MM:SS format: "02:00:00", "2:30:00", "00:30:00"
- H:MM format: "2:30" (interpreted as hours:minutes)
Returns the duration in time.Duration format.
func ParseSizeToMB ¶
ParseSizeToMB converts strings like "10G", "500M", "1024" into Megabytes (int). Default unit is MB if no suffix is provided.
func PrintDebug ¶
func PrintDebug(format string, a ...interface{})
PrintDebug prints a debug message with a Gray tag (only if DebugMode is true). Output: [CNT] [DBG] Executing: rm -rf /tmp/foo
func PrintError ¶
func PrintError(format string, a ...interface{})
PrintError prints an error message with a Red tag to Stderr. Output: [CNT][ERR] Something failed.
func PrintHint ¶
func PrintHint(format string, a ...interface{})
PrintHint prints a helpful hint with a Cyan tag. Output: [CNT][HINT] Try running with --force.
func PrintMessage ¶
func PrintMessage(format string, a ...interface{})
PrintMessage prints a standard info message. Output: [CNT] Message...
func PrintNote ¶
func PrintNote(format string, a ...interface{})
PrintNote prints a note with a Magenta tag. Output: [CNT][NOTE] This might take a while.
func PrintSuccess ¶
func PrintSuccess(format string, a ...interface{})
PrintSuccess prints a success message with a Green tag. Output: [CNT][SUCCESS] Operation complete.
func PrintWarning ¶
func PrintWarning(format string, a ...interface{})
PrintWarning prints a warning with a Yellow tag to Stderr. Output: [CNT][WARN] Disk is almost full.
func ShareToUGORecursive ¶
ShareToUGORecursive recursively sets permissions to share files with user, group, and others. Files: ug+rw,o+r (0664) Directories: ug+rwx,o+rx (0775) This matches the Python implementation's share_to_ugo_recursive function.
func ShouldAnswerYes ¶
func ShouldAnswerYes() bool
ShouldAnswerYes checks if we should automatically answer yes to prompts Returns true if --yes flag is set, false otherwise
func StyleAction ¶
StyleAction formats verbs or active operations (Yellow).
func StyleCommand ¶
StyleCommand formats shell commands or flags (Gray/Faint).
func StyleDebug ¶
StyleDebug formats low-level technical info (Gray).
func StyleError ¶
StyleError formats critical failure messages (Red).
func StyleHighlight ¶
StyleHighlight formats search matches or highlighted text (Yellow Bold).
func StyleNumber ¶
func StyleNumber(num interface{}) string
StyleNumber formats counts, sizes, or IDs (Magenta).
func StyleSuccess ¶
StyleSuccess formats success messages (Green).
func StyleWarning ¶
StyleWarning formats non-critical warnings (Yellow).
Types ¶
This section is empty.