Skip to content

Commit

Permalink
updated project
Browse files Browse the repository at this point in the history
  • Loading branch information
memob0x committed Dec 14, 2024
1 parent 7eb0732 commit 99a4a73
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.23

# Checks-out the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.23

- uses: actions/checkout@v2

Expand Down
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2024 memob0x

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# retroarch-links-generator

[![CI](https://github.com/memob0x/retroarch-links-generator/workflows/Go/badge.svg)](https://github.com/memob0x/retroarch-links-generator/actions?query=workflow%3AGo) [![Go Report Card](https://goreportcard.com/badge/github.com/memob0x/retroarch-links-generator)](https://goreportcard.com/report/github.com/memob0x/retroarch-links-generator) [![GoDoc](https://godoc.org/github.com/memob0x/retroarch-links-generator?status.svg)](http://godoc.org/github.com/memob0x/retroarch-links-generator) [![version](https://img.shields.io/github/v/tag/memob0x/retroarch-links-generator?label=version)](https://img.shields.io/github/v/tag/memob0x/retroarch-links-generator?label=version)

Generate links to RetroArch playlists entries and launch them like normal games.

![how-it-works](./docs/how-it-works.gif)
Expand All @@ -20,10 +22,10 @@ It's possible to parse only **certain playlists** with the following command:

```console
retroarch-links-generator /executable /dest ./playlist-1.lpl,./playlist-2.lpl
```
```

It's possible to directly write **[Steam](https://it.wikipedia.org/wiki/Steam_(informatica)) library shortcuts** providing a path to the right vdf file, usually (steam installation path)/userdata/(your user id)/config/shortcuts.vdf

```console
retroarch-links-generator /the/retroarch/executable /the/steam/shortcuts.vdf
```
```
4 changes: 2 additions & 2 deletions utils/convert_shortcut_to_vdf_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func ConvertShortcutToVdfMap(shortcut SteamShortcut) (vdf.Map, error) {
continue
}

switch a.(type) {
switch b := a.(type) {
case float64:
shortcutMapSafe[index] = uint32(math.Round(a.(float64)))
shortcutMapSafe[index] = uint32(math.Round(b))
case uint32, string, vdf.Map:
shortcutMapSafe[index] = a
default:
Expand Down
8 changes: 4 additions & 4 deletions utils/create_win_os_exe_shortcut_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func testCreateWinOsShortcutWindows(t *testing.T) {
os.Remove("./foo-link.lnk")
}

func testCreateWinOsShortcutNonWindows(t *testing.T) {
func testCreateWinOsShortcutNonWindows(_ *testing.T) {
if IS_OS_WINDOWS {
return
}
Expand All @@ -51,7 +51,7 @@ func TestCreateWinOsShortcut(t *testing.T) {

err,

WinOsExeShortcutCreationInputError,
ErrWinOsExeShortcutCreationInput,

"Should return an error if a source without .exe extension is passed",
)
Expand All @@ -69,7 +69,7 @@ func TestCreateWinOsShortcut(t *testing.T) {

err,

WinOsExeShortcutCreationInputError,
ErrWinOsExeShortcutCreationInput,

"Should return an error if a target without .lnk extension is passed",
)
Expand All @@ -87,7 +87,7 @@ func TestCreateWinOsShortcut(t *testing.T) {

err,

WinOsExeShortcutCreationInputError,
ErrWinOsExeShortcutCreationInput,

"Should not return an error if valid *.exe source and *.lnk target are passed",
)
Expand Down
2 changes: 1 addition & 1 deletion utils/get_link_file_infos_from_playlist_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type LinkInfo struct {
Content string
}

var ErrorInvalidCore = errors.New("Alert, invalid core")
var ErrorInvalidCore = errors.New("alert, invalid core")

func GetLinkFileInfosFromPlaylistItem(
playlistItem RetroArchPlaylistItem,
Expand Down
4 changes: 2 additions & 2 deletions utils/get_vbs_script_shortcut_creator_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
)

var WinOsExeShortcutCreationInputError = errors.New("Invalid executable paths provided")
var ErrWinOsExeShortcutCreationInput = errors.New("invalid executable paths provided")

func GetVbsScriptShortcutCreatorContent(
shortcutSourceFilePath string,
Expand All @@ -16,7 +16,7 @@ func GetVbsScriptShortcutCreatorContent(
shortcutArguments string,
) (string, error) {
if !strings.HasSuffix(shortcutSourceFilePath, ".exe") || !strings.HasSuffix(shortcutTargetFilePath, ".lnk") {
return "", WinOsExeShortcutCreationInputError
return "", ErrWinOsExeShortcutCreationInput
}

var linkCreationCommandString = fmt.Sprintf(`Set oWS = WScript.CreateObject("WScript.Shell")
Expand Down
6 changes: 3 additions & 3 deletions utils/get_vbs_script_shortcut_creator_content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestGetVbsScriptShortcutCreatorContent(t *testing.T) {

err,

WinOsExeShortcutCreationInputError,
ErrWinOsExeShortcutCreationInput,

"Should return an error if a source without .exe extension is passed",
)
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestGetVbsScriptShortcutCreatorContent(t *testing.T) {

err,

WinOsExeShortcutCreationInputError,
ErrWinOsExeShortcutCreationInput,

"Should return an error if a target without .lnk extension is passed",
)
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestGetVbsScriptShortcutCreatorContent(t *testing.T) {

err,

WinOsExeShortcutCreationInputError,
ErrWinOsExeShortcutCreationInput,

"Should not return an error if valid *.exe source and *.lnk target are passed",
)
Expand Down
18 changes: 17 additions & 1 deletion utils/parse_command_line_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
)

var ErrorRetroArchExecutablePath = errors.New("No retroarch executable path specified.")
var ErrorRetroArchExecutablePath = errors.New("no retroarch executable path specified")

func ParseCommandLineArgs(args []string) (string, string, string, bool, error) {
var argsCount = len(args)
Expand All @@ -15,18 +15,34 @@ func ParseCommandLineArgs(args []string) (string, string, string, bool, error) {

outputDestPath, err := filepath.Abs(".")

if err != nil {
return "", "", "", false, err
}

if argsCount >= 2 {
retroArchExecutablePath, err = filepath.Abs(args[1])
} else {
err = ErrorRetroArchExecutablePath
}

if err != nil {
return "", "", "", false, err
}

retroArchPlaylists, err := filepath.Abs(filepath.Dir(retroArchExecutablePath) + "/playlists")

if err != nil {
return "", "", "", false, err
}

if argsCount >= 3 {
outputDestPath, err = filepath.Abs(args[2])
}

if err != nil {
return "", "", "", false, err
}

var isOutputPathVdfFile bool = strings.HasSuffix(outputDestPath, ".vdf")

if argsCount >= 4 {
Expand Down
2 changes: 1 addition & 1 deletion utils/read_binary_vdf_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/wakeful-cloud/vdf"
)

var ErrorVdfNotExists = errors.New("No vdf file.")
var ErrorVdfNotExists = errors.New("no vdf file")

func ReadBinaryVdfFile(vdfFilePath string) (vdf.Map, error) {
var vdfMap vdf.Map
Expand Down
2 changes: 1 addition & 1 deletion utils/read_shortcuts_vdf_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type SteamShortcut struct {
Tags vdf.Map `json:"tags"`
}

var ErrorInvalidVdfFile = errors.New("Not a shortcuts vdf")
var ErrorInvalidVdfFile = errors.New("not a shortcuts vdf")

func ReadShortcutsVdfFile(vdfFilePath string) ([]SteamShortcut, error) {
vdfMap, err := ReadBinaryVdfFile(vdfFilePath)
Expand Down
6 changes: 3 additions & 3 deletions utils/write_playlists_items_links.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"path/filepath"
)

var ErrorLinkCreation error = errors.New("Link creation error")
var ErrorOutputFolder error = errors.New("Error creating output folder.")
var ErrorExistentFile error = errors.New("Output path is an existent file.")
var ErrorLinkCreation error = errors.New("link creation error")
var ErrorOutputFolder error = errors.New("error creating output folder")
var ErrorExistentFile error = errors.New("output path is an existent file")

func WritePlaylistsItemsLinks(playlists []PlaylistInfo, retroArchExecutablePath string, outputLinksPath string) error {
for _, playlist := range playlists {
Expand Down
2 changes: 1 addition & 1 deletion utils/write_playlists_items_links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
)

func testWritePlaylistItemsLinksWindows(t *testing.T) {
func testWritePlaylistItemsLinksWindows(_ *testing.T) {
if !IS_OS_WINDOWS {
return
}
Expand Down

0 comments on commit 99a4a73

Please sign in to comment.