Skip to content

Commit

Permalink
Merge pull request #10 from PentHertz/dev
Browse files Browse the repository at this point in the history
Merge dev for v0.5.0
  • Loading branch information
FlUxIuS authored Sep 19, 2024
2 parents b934e97 + adb09de commit 3d2179a
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 886 deletions.
4 changes: 2 additions & 2 deletions go/rfswift/cli/rfcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var runCmd = &cobra.Command{
}
rfdock.DockerSetXDisplay(XDisplay)
rfdock.DockerSetShell(ExecCmd)
rfdock.DockerAddBiding(ExtraBind)
rfdock.DockerAddBinding(ExtraBind)
rfdock.DockerSetImage(DImage)
rfdock.DockerSetExtraHosts(ExtraHost)
rfdock.DockerSetPulse(PulseServer)
Expand Down Expand Up @@ -308,7 +308,7 @@ func init() {
HostPulseAudioCmd.AddCommand(HostPulseAudioUnloadCmd)
HostPulseAudioEnableCmd.Flags().StringVarP(&PulseServer, "pulseserver", "s", "tcp:127.0.0.1:34567", "pulse server address (by default: 'tcp:127.0.0.1:34567')")

DeleteCmd.Flags().StringVarP(&ContID, "image", "i", "", "image ID or tag")
DeleteCmd.Flags().StringVarP(&DImage, "image", "i", "", "image ID or tag")
removeCmd.Flags().StringVarP(&ContID, "container", "c", "", "container to remove")
installCmd.Flags().StringVarP(&ExecCmd, "install", "i", "", "function for installation")
installCmd.Flags().StringVarP(&ContID, "container", "c", "", "container to run")
Expand Down
32 changes: 28 additions & 4 deletions go/rfswift/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package common
import (
"fmt"
"os"
"os/user"
"path/filepath"
"runtime"
"strings"
)

var Version = "0.4.9"
var Version = "0.5.0"
var Branch = "main"
var ascii_art = `
Expand Down Expand Up @@ -87,19 +88,42 @@ func PrintSuccessMessage(message string) {
fmt.Printf("%s[+] %s%s%s\n", green, white, message, reset)
}

func PrintWarningMessage(message string) {
yellow := "\033[33m" // Yellow color for warnings or notices
white := "\033[37m"
reset := "\033[0m"
fmt.Printf("%s[!] %s%s%s\n", yellow, white, message, reset)
}

func PrintInfoMessage(message interface{}) {
blue := "\033[34m"
reset := "\033[0m"
fmt.Printf("%s[i] %v%s\n", blue, message, reset)
}

func ConfigFileByPlatform() string {
var configPath string

// Get the current user, handling cases where sudo is used
homeDir := os.Getenv("HOME") // Default to the HOME environment variable
if sudoUser := os.Getenv("SUDO_USER"); sudoUser != "" {
// Use SUDO_USER to find the original user's home directory
userInfo, err := user.Lookup(sudoUser)
if err == nil {
homeDir = userInfo.HomeDir
}
}

// Determine the platform-specific directory
switch runtime.GOOS {
case "windows":
configPath = filepath.Join(os.Getenv("APPDATA"), "rfswift", "config.ini")
case "darwin":
configPath = filepath.Join(os.Getenv("HOME"), "Library", "Application Support", "rfswift", "config.ini")
configPath = filepath.Join(homeDir, "Library", "Application Support", "rfswift", "config.ini")
case "linux":
configPath = filepath.Join(os.Getenv("HOME"), ".config", "rfswift", "config.ini")
configPath = filepath.Join(homeDir, ".config", "rfswift", "config.ini")
default:
configPath = "config.ini"
}
return configPath
}
}
11 changes: 8 additions & 3 deletions go/rfswift/dock/dockerutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ func DockerSetShell(shellcmd string) {
}
}

func DockerAddBiding(addbindings string) {
/* Add extra bindings to the Docker container to run
func DockerAddBinding(addbindings string) {
/* Add extra bindings to the Docker container
in(1): string of bindings separated by commas
*/
if addbindings != "" {
dockerObj.extrabinding = addbindings
// Check if extrabinding already has content, and append with a comma if it does
if dockerObj.extrabinding != "" {
dockerObj.extrabinding += "," + addbindings
} else {
dockerObj.extrabinding = addbindings
}
}
}

Expand Down
Loading

0 comments on commit 3d2179a

Please sign in to comment.