Skip to content

Commit

Permalink
First prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
mportizlunyov committed Nov 24, 2024
1 parent 6c1839f commit 6eb9f6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/mportizlunyov/go-unix-pkg-detector

replace github.com/mportizlunyov/go-unix-pkg-detector => github.com/mportizlunyov/go-unix-pkg-detector v0.0.2
replace github.com/mportizlunyov/go-unix-pkg-detector => github.com/mportizlunyov/go-unix-pkg-detector v1.0.0

go 1.23
21 changes: 11 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Written by Mikhail Ortiz-Lunyov
//
// Version 0.0.2
// Version 1.0.0-release

/*
Go UNIX package detector
Expand Down Expand Up @@ -28,9 +28,9 @@ import (

// Constants related to versions
const (
short_VERSION_NUM string = "0.0.1"
version_NAME string = "November 18th, 2024"
dev_MARKER string = "-alpha"
short_VERSION_NUM string = "1.0.0"
version_NAME string = "November 23rd, 2024"
dev_MARKER string = "-release"
full_VERSION string = "v" + short_VERSION_NUM + dev_MARKER + " ( " + version_NAME + ")"
)

Expand Down Expand Up @@ -108,8 +108,8 @@ func pruneSlice(sliceToPrune []string) []string {
return prunedSliceToReturn
}

// Method used to check if directory contains binary with the name of a package manager listed above.
func checkPkgManBinaries(directory string, official bool) []string {
// Method used to check if directory contains binary with the name of a listed package manager
func checkPkgManBinaryName(directory string, official bool) []string {
// Initialise variables
var returnPkgMan []string = []string{}

Expand Down Expand Up @@ -149,13 +149,13 @@ func searchUserPATH() ([]string, []string) {
// // Get the path of the directories in $PATH variable
var pathDirectories []string = strings.Split(os.Getenv("PATH"), ":")
// // Get the names of identified package managers from a PATH directory
var identifiedOfficialPkgMan []string = []string{}
var identifiedAlternativePkgMan []string = []string{}
var identifiedOfficialPkgMan []string
var identifiedAlternativePkgMan []string

// Iterate through user's $PATH variable, checking the binaries that exist
for _, directory := range pathDirectories {
identifiedOfficialPkgMan = append(identifiedOfficialPkgMan, checkPkgManBinaries(directory, true)...)
identifiedAlternativePkgMan = append(identifiedAlternativePkgMan, checkPkgManBinaries(directory, false)...)
identifiedOfficialPkgMan = append(identifiedOfficialPkgMan, checkPkgManBinaryName(directory, true)...)
identifiedAlternativePkgMan = append(identifiedAlternativePkgMan, checkPkgManBinaryName(directory, false)...)
}

return identifiedOfficialPkgMan, identifiedAlternativePkgMan
Expand All @@ -176,6 +176,7 @@ func main() {
fmt.Println(full_VERSION)
os.Exit(0)
}

official, alternative := Report()
fmt.Println("Official package managers: ", official)
fmt.Println("Alternative package mangers: ", alternative)
Expand Down

0 comments on commit 6eb9f6b

Please sign in to comment.