Skip to content

Commit

Permalink
comments: change first character from upper- to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
Tch1b0 committed Jul 22, 2022
1 parent 433e19d commit 525b301
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ jobs:
with:
go-version: "1.18"

# compile windows executable
- name: Compile to ${{ matrix.os-name }}
if: ${{ startsWith(matrix.os-name, 'windows') }}
env:
GOARCH: ${{ matrix.go-arch }}
GOOS: ${{ matrix.go-os }}
run: go build -o ./build/ppm_${{ matrix.os-name }}.exe -ldflags "-X main.BuildVersion=${{ github.event.release.tag_name }}"

# compile linux/darwin executable
- name: Compile to ${{ matrix.os-name }}
if: ${{ !startsWith(matrix.os-name, 'windows') }}
env:
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func installDependency(config *utility.PpmConfig, paths utility.Paths, dependenc
return nil
}

// Iterate over dependencies and install them if needed
// iterate over dependencies and install them if needed
for _, dep := range subConfig.Dependencies {
if !config.HasSubDependency(dep) {
installDependency(config, paths, dep, true)
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/urfave/cli/v2"
)

// The update method is called by the cli
// It updates all dependencies
// the update method is called by the cli
// it updates all dependencies
func update(ctx *cli.Context) error {
paths, config, err := utility.GetPathsAndConfig()
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/utility/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
git "github.com/go-git/go-git/v5"
)

// Clone a certain github repository into a certain folder
// clone a certain github repository into a certain folder
func Clone(path string, repoName string, version string) error {
// The clonable name of the repository
// the clonable name of the repository
var repository string
// The name of the repository
// the name of the repository
var name string

if IsUrl(repoName) {
Expand All @@ -37,7 +37,7 @@ func Clone(path string, repoName string, version string) error {
return err
}

// Update a certain repository
// update a certain repository
func Update(path string) error {
repo, err := git.PlainOpen(path)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/utility/loading.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ type LoadingVisualization struct {
finished chan any
}

// Create and start a new LoadingVisualziation instance
// create and start a new LoadingVisualziation instance
func StartLoading() *LoadingVisualization {
l := LoadingVisualization{}
l.Start()
return &l
}

// Prepare and run the loading animation in a new goroutine
// prepare and run the loading animation in a new goroutine
func (l *LoadingVisualization) Start() {
if l.AnimationFrames == nil {
l.AnimationFrames = []string{"|", "/", "-", "\\", "|"}
Expand All @@ -28,7 +28,7 @@ func (l *LoadingVisualization) Start() {
go l.Run(10)
}

// Run the loading animation
// run the loading animation
func (l *LoadingVisualization) Run(speed time.Duration) {
index := 0
for {
Expand All @@ -48,7 +48,7 @@ func (l *LoadingVisualization) Run(speed time.Duration) {
}
}

// Stop the loading animation
// stop the loading animation
func (l *LoadingVisualization) Stop() {
l.finished <- nil
}
16 changes: 8 additions & 8 deletions pkg/utility/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ import (
"strings"
)

// Access different important paths in the GD project
// access different important paths in the GD project
type Paths struct {
/*
The root of the project.
the root of the project.
If the project is a game, the root is on the same level
if the project is a game, the root is on the same level
as the godot config files.
If the project is a plugin, the root is somewhere under /addons
if the project is a plugin, the root is somewhere under /addons
*/
Root string

// The path to the addons folder
// the path to the addons folder
Addons string

// The path to the ppm.json config file
// the path to the ppm.json config file
ConfigFile string
}

// Create a new paths instance from the root path
// create a new paths instance from the root path
func CreatePaths(rootPath string) Paths {
var addons string
if strings.HasSuffix(filepath.Dir(rootPath), "addons") {
Expand All @@ -41,7 +41,7 @@ func CreatePaths(rootPath string) Paths {
}
}

// Create a new paths instance from the current working directory
// create a new paths instance from the current working directory
func CreatePathsFromCwd() (Paths, error) {
rootPath, err := os.Getwd()
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions pkg/utility/ppmconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,41 @@ import (
"strings"
)

// Representing a ppm.json configuration file
// representing a ppm.json configuration file
type PpmConfig struct {
IsPlugin bool `json:"plugin"`
Dependencies []string `json:"dependencies"`
SubDependencies []string `json:"sub-dependencies"`
filePath string
}

// Add an item safely to the Dependencies property
// add an item safely to the Dependencies property
func (ppm *PpmConfig) AddDependency(dependency string) {
ppm.Dependencies = append(ppm.Dependencies, dependency)
ppm.Write()
}

// Add an item safely to the sub-dependencies property
// add an item safely to the sub-dependencies property
func (ppm *PpmConfig) AddSubDependency(dependency string) {
ppm.SubDependencies = append(ppm.SubDependencies, dependency)
ppm.Write()
}

// Remove ALL (sub)dependencies
// remove ALL (sub)dependencies
func (ppm *PpmConfig) RemoveAllDependencies() {
ppm.Dependencies = []string{}
ppm.SubDependencies = []string{}
ppm.Write()
}

// Remove an item safely from the Dependencies property by its name
// remove an item safely from the Dependencies property by its name
func (ppm *PpmConfig) RemoveSubDependency(dependency string) {
index := IndexOf(dependency, ppm.SubDependencies)
ppm.SubDependencies = append(ppm.SubDependencies[:index], ppm.SubDependencies[index+1:]...)
ppm.Write()
}

// Remove an item safely from the sub-dependencies property by its name
// remove an item safely from the sub-dependencies property by its name
func (ppm *PpmConfig) RemoveDependency(dependency string) {
if len(ppm.Dependencies) == 1 {
ppm.Dependencies = []string{}
Expand All @@ -56,12 +56,12 @@ func (ppm *PpmConfig) RemoveDependency(dependency string) {
ppm.Write()
}

// Check wether the config file has a certain dependency
// check wether the config file has a certain dependency
func (ppm PpmConfig) HasDependency(dependency string) bool {
return SliceContains(dependency, ppm.Dependencies)
}

// Check wether the config file has a certain sub-dependency
// check wether the config file has a certain sub-dependency
func (ppm PpmConfig) HasSubDependency(dependency string) bool {
return SliceContains(dependency, ppm.SubDependencies)
}
Expand All @@ -78,7 +78,7 @@ func (ppm PpmConfig) PrettyPrint() {
fmt.Printf("this project is a %s\ndependencies: %v\nsubdependencies: %v", ppmType, dependencies, subDependencies)
}

// Write the current state of the configuartion to the config file
// write the current state of the configuartion to the config file
func (ppm PpmConfig) Write() error {
content, err := json.MarshalIndent(ppm, "", " ")
if err != nil {
Expand All @@ -93,7 +93,7 @@ func (ppm PpmConfig) Write() error {
return nil
}

// Parse the ppm.json file to an object
// parse the ppm.json file to an object
func ParsePpmConfig(filePath string) (PpmConfig, error) {
file, err := os.Open(filePath)
if err != nil {
Expand All @@ -114,7 +114,7 @@ func ParsePpmConfig(filePath string) (PpmConfig, error) {
return config, nil
}

// Create a new ppm.json file
// create a new ppm.json file
func CreateNewPpmConfig(path string) error {
configPath := filepath.Join(path, "ppm.json")

Expand Down
10 changes: 5 additions & 5 deletions pkg/utility/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/fatih/color"
)

// Check wether an absolute path exists
// check wether an absolute path exists
func DoesPathExist(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
Expand All @@ -24,7 +24,7 @@ func DoesPathExist(path string) (bool, error) {
return false, err
}

// Create a certain directory if it doesn't exist
// create a certain directory if it doesn't exist
func CheckOrCreateDir(path string) error {
pathExisting, _ := DoesPathExist(path)
if pathExisting {
Expand All @@ -39,7 +39,7 @@ func CheckOrCreateDir(path string) error {
return nil
}

// Get the index of a certain item in a string slice
// get the index of a certain item in a string slice
func IndexOf[t comparable](target t, data []t) int {
for index, value := range data {
if target == value {
Expand All @@ -49,7 +49,7 @@ func IndexOf[t comparable](target t, data []t) int {
return -1
}

// Check wether a certain item exists in a string slice
// check wether a certain item exists in a string slice
func SliceContains[t comparable](target t, data []t) bool {
for _, v := range data {
if v == target {
Expand Down Expand Up @@ -117,7 +117,7 @@ func SliceToString(slice []string, seperator string) string {
return str
}

// Get the first predicate match of the slice
// get the first predicate match of the slice
//
// returns nil if none of the items match
func GetFirstMatch[t any](slice []t, predicate func(t, int) bool) *t {
Expand Down

0 comments on commit 525b301

Please sign in to comment.