fix sorting and cleanup toml sort bash script
This commit is contained in:
@@ -22,16 +22,16 @@ task_list = "FM"
|
|||||||
name = "Emulators"
|
name = "Emulators"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "RetroArch Game Emulator"
|
name = "Blastem"
|
||||||
description = "Frontend for emulators, game engines and media players. NO Games or Bios' are included"
|
description = "A Genesis emulator. NO Games are included"
|
||||||
script = "emulators/retroarch.sh"
|
script = "emulators/sega/blastem.sh"
|
||||||
task_list = "FM"
|
task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
# [[data.entries]]
|
||||||
name = "snes9x"
|
# name = "Yabause"
|
||||||
description = "Super Nintendo Emulator. NO Games are included"
|
# description = "A Sega Saturn emulator"
|
||||||
script = "emulators/nintendo/snes9x.sh"
|
# script = "emulators/sega/yabause.sh"
|
||||||
task_list = "FM"
|
# task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "bsnes"
|
name = "bsnes"
|
||||||
@@ -39,6 +39,36 @@ description = "Super Nintendo Emulator. NO Games are included"
|
|||||||
script = "emulators/nintendo/bsnes.sh"
|
script = "emulators/nintendo/bsnes.sh"
|
||||||
task_list = "FM"
|
task_list = "FM"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "Dolphin Emulator"
|
||||||
|
description = "GameCube and Wii Emulator. NO Games are included"
|
||||||
|
script = "emulators/nintendo/dolphin-emu.sh"
|
||||||
|
task_list = "FM"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "Flycast"
|
||||||
|
description = "A Dreamcase emulator. NO Games are included"
|
||||||
|
script = "emulators/sega/flycast.sh"
|
||||||
|
task_list = "FM"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "Gopher 64"
|
||||||
|
description = "N64 Emulator. NO Games are included"
|
||||||
|
script = "emulators/nintendo/gopher64.sh"
|
||||||
|
task_list = "FM"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "Kronos"
|
||||||
|
description = "A Sega Saturn emulator. NO Games are included"
|
||||||
|
script = "emulators/sega/kronos.sh"
|
||||||
|
task_list = "FM"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "MelonDS"
|
||||||
|
description = "Nintendo DS and DSi Emulator. NO Games are included"
|
||||||
|
script = "emulators/nintendo/melonds.sh"
|
||||||
|
task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "mGBA"
|
name = "mGBA"
|
||||||
description = "Nintendo Game Boy Advance Emulator. NO Games are included"
|
description = "Nintendo Game Boy Advance Emulator. NO Games are included"
|
||||||
@@ -52,21 +82,27 @@ script = "emulators/nintendo/mupen64plus.sh"
|
|||||||
task_list = "FM"
|
task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Gopher 64"
|
name = "PCSX2"
|
||||||
description = "N64 Emulator. NO Games are included"
|
description = "A Playstation 2 emulator. NO Games or Bios' are included"
|
||||||
script = "emulators/nintendo/gopher64.sh"
|
script = "emulators/playstation/pcsx2.sh"
|
||||||
task_list = "FM"
|
task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Dolphin Emulator"
|
name = "Play!"
|
||||||
description = "GameCube and Wii Emulator. NO Games are included"
|
description = "An Experimental Playstation 2 emulator. NO Games or Bios' are included"
|
||||||
script = "emulators/nintendo/dolphin-emu.sh"
|
script = "emulators/playstation/play-emu.sh"
|
||||||
task_list = "FM"
|
task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "MelonDS"
|
name = "RetroArch Game Emulator"
|
||||||
description = "Nintendo DS and DSi Emulator. NO Games are included"
|
description = "Frontend for emulators, game engines and media players. NO Games or Bios' are included"
|
||||||
script = "emulators/nintendo/melonds.sh"
|
script = "emulators/retroarch.sh"
|
||||||
|
task_list = "FM"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "RPCS3"
|
||||||
|
description = "A Playstation 3 emulator. NO Games or Bios' are included"
|
||||||
|
script = "emulators/playstation/rpcs3.sh"
|
||||||
task_list = "FM"
|
task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
@@ -82,45 +118,9 @@ task_list = "FM"
|
|||||||
# task_list = "FM"
|
# task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "PCSX2"
|
name = "snes9x"
|
||||||
description = "A Playstation 2 emulator. NO Games or Bios' are included"
|
description = "Super Nintendo Emulator. NO Games are included"
|
||||||
script = "emulators/playstation/pcsx2.sh"
|
script = "emulators/nintendo/snes9x.sh"
|
||||||
task_list = "FM"
|
|
||||||
|
|
||||||
[[data.entries]]
|
|
||||||
name = "Play!"
|
|
||||||
description = "An Experimental Playstation 2 emulator. NO Games or Bios' are included"
|
|
||||||
script = "emulators/playstation/play-emu.sh"
|
|
||||||
task_list = "FM"
|
|
||||||
|
|
||||||
[[data.entries]]
|
|
||||||
name = "RPCS3"
|
|
||||||
description = "A Playstation 3 emulator. NO Games or Bios' are included"
|
|
||||||
script = "emulators/playstation/rpcs3.sh"
|
|
||||||
task_list = "FM"
|
|
||||||
|
|
||||||
[[data.entries]]
|
|
||||||
name = "Blastem"
|
|
||||||
description = "A Genesis emulator. NO Games are included"
|
|
||||||
script = "emulators/sega/blastem.sh"
|
|
||||||
task_list = "FM"
|
|
||||||
|
|
||||||
# [[data.entries]]
|
|
||||||
# name = "Yabause"
|
|
||||||
# description = "A Sega Saturn emulator"
|
|
||||||
# script = "emulators/sega/yabause.sh"
|
|
||||||
# task_list = "FM"
|
|
||||||
|
|
||||||
[[data.entries]]
|
|
||||||
name = "Kronos"
|
|
||||||
description = "A Sega Saturn emulator. NO Games are included"
|
|
||||||
script = "emulators/sega/kronos.sh"
|
|
||||||
task_list = "FM"
|
|
||||||
|
|
||||||
[[data.entries]]
|
|
||||||
name = "Flycast"
|
|
||||||
description = "A Dreamcase emulator. NO Games are included"
|
|
||||||
script = "emulators/sega/flycast.sh"
|
|
||||||
task_list = "FM"
|
task_list = "FM"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
|
|||||||
+88
-41
@@ -1,6 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Sort all tab_data.toml files in the core/tabs directory
|
# Sort all tab_data.toml files in the core/tabs directory
|
||||||
|
# - Sorts [[data]] blocks alphabetically by name
|
||||||
|
# - Sorts [[data.entries]] within each block alphabetically by name
|
||||||
|
# - Places blocks with entries before blocks without entries
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Sorting all tab_data.toml files..."
|
echo "Sorting all tab_data.toml files..."
|
||||||
@@ -10,78 +14,121 @@ find core/tabs -name "tab_data.toml" | while IFS= read -r file; do
|
|||||||
|
|
||||||
awk '
|
awk '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
data_block = ""
|
|
||||||
data_name = ""
|
|
||||||
data_count = 0
|
|
||||||
in_data = 0
|
in_data = 0
|
||||||
header = ""
|
in_entry = 0
|
||||||
|
data_count = 0
|
||||||
|
entry_count = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Capture header (lines before first [[data]])
|
# Capture file header (lines before first [[data]])
|
||||||
!in_data && !/^\[\[data\]\]$/ {
|
!in_data && !/^\[\[data\]\]$/ {
|
||||||
header = header $0 "\n"
|
header = header $0 "\n"
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start of a new [[data]] section
|
# Start of new [[data]] block
|
||||||
/^\[\[data\]\]$/ {
|
/^\[\[data\]\]$/ {
|
||||||
# Save previous data block if exists
|
save_entry_block()
|
||||||
if (data_block != "") {
|
save_data_block()
|
||||||
data_blocks[data_name] = data_block
|
data_header = $0 "\n"
|
||||||
data_names[++data_count] = data_name
|
|
||||||
# Check if block has entries
|
|
||||||
if (data_block ~ /\[\[data\.entries\]\]/) {
|
|
||||||
has_entries[data_name] = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# Start new data block
|
|
||||||
data_block = $0 "\n"
|
|
||||||
in_data = 1
|
in_data = 1
|
||||||
|
in_entry = 0
|
||||||
data_name = ""
|
data_name = ""
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
# Inside a [[data]] block - collect everything until next [[data]]
|
# Start of new [[data.entries]] block
|
||||||
|
in_data && /^\[\[data\.entries\]\]$/ {
|
||||||
|
save_entry_block()
|
||||||
|
entry_block = $0 "\n"
|
||||||
|
in_entry = 1
|
||||||
|
entry_name = ""
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
# Lines inside [[data.entries]]
|
||||||
|
in_entry {
|
||||||
|
entry_block = entry_block $0 "\n"
|
||||||
|
if ($0 ~ /^name = / && !entry_name) {
|
||||||
|
entry_name = extract_name($0)
|
||||||
|
}
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
# Lines inside [[data]] but outside [[data.entries]]
|
||||||
in_data {
|
in_data {
|
||||||
data_block = data_block $0 "\n"
|
data_header = data_header $0 "\n"
|
||||||
# Extract the name field from [[data]] section
|
if ($0 ~ /^name = / && !data_name) {
|
||||||
if ($0 ~ /^name = / && data_name == "") {
|
data_name = extract_name($0)
|
||||||
gsub(/^name = "/, "", $0)
|
|
||||||
gsub(/".*$/, "", $0)
|
|
||||||
data_name = tolower($0)
|
|
||||||
}
|
}
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
# Save last data block
|
save_entry_block()
|
||||||
if (data_block != "") {
|
save_data_block()
|
||||||
data_blocks[data_name] = data_block
|
print_sorted_output()
|
||||||
data_names[++data_count] = data_name
|
}
|
||||||
# Check if block has entries
|
|
||||||
if (data_block ~ /\[\[data\.entries\]\]/) {
|
# Helper function to extract and normalize name field
|
||||||
|
function extract_name(line) {
|
||||||
|
gsub(/^name = "/, "", line)
|
||||||
|
gsub(/".*$/, "", line)
|
||||||
|
return tolower(line)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Save current entry block
|
||||||
|
function save_entry_block() {
|
||||||
|
if (entry_block && entry_name) {
|
||||||
|
entry_blocks[entry_name] = entry_block
|
||||||
|
entry_names[++entry_count] = entry_name
|
||||||
|
entry_block = ""
|
||||||
|
entry_name = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Save current data block with sorted entries
|
||||||
|
function save_data_block() {
|
||||||
|
if (data_name) {
|
||||||
|
# Sort and append entries
|
||||||
|
if (entry_count > 0) {
|
||||||
|
n = asort(entry_names, sorted)
|
||||||
|
for (i = 1; i <= n; i++) {
|
||||||
|
data_header = data_header entry_blocks[sorted[i]]
|
||||||
|
}
|
||||||
has_entries[data_name] = 1
|
has_entries[data_name] = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data_blocks[data_name] = data_header
|
||||||
|
data_names[++data_count] = data_name
|
||||||
|
|
||||||
|
# Reset for next block
|
||||||
|
entry_count = 0
|
||||||
|
delete entry_blocks
|
||||||
|
delete entry_names
|
||||||
|
data_header = ""
|
||||||
|
data_name = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print header
|
# Print sorted output
|
||||||
|
function print_sorted_output() {
|
||||||
printf "%s", header
|
printf "%s", header
|
||||||
|
|
||||||
# Sort and print data blocks - first those with entries, then those without
|
|
||||||
if (data_count > 0) {
|
if (data_count > 0) {
|
||||||
n = asort(data_names, sorted_names)
|
n = asort(data_names, sorted)
|
||||||
# First pass: blocks with entries
|
|
||||||
|
# First: blocks with entries
|
||||||
for (i = 1; i <= n; i++) {
|
for (i = 1; i <= n; i++) {
|
||||||
name = sorted_names[i]
|
if (has_entries[sorted[i]]) {
|
||||||
if (has_entries[name]) {
|
printf "%s", data_blocks[sorted[i]]
|
||||||
printf "%s", data_blocks[name]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Second pass: blocks without entries
|
|
||||||
|
# Second: blocks without entries
|
||||||
for (i = 1; i <= n; i++) {
|
for (i = 1; i <= n; i++) {
|
||||||
name = sorted_names[i]
|
if (!has_entries[sorted[i]]) {
|
||||||
if (!has_entries[name]) {
|
printf "%s", data_blocks[sorted[i]]
|
||||||
printf "%s", data_blocks[name]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user