Skip to content

πŸ—ΊοΈ A Go-based CLI tool that bulk downloads Rust game maps data from RustMaps API with automatic pagination and rate limiting.

License

Notifications You must be signed in to change notification settings

kWAYTV/rustmaps-downloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RustMaps CLI

A command-line interface tool for interacting with the RustMaps API, built in Go. The update-config command is specifically designed to work with Rust Wipe Bot configuration files.

Build Status codecov Go Report Card Latest Release

Features

  • CLI-based interface for easy interaction
  • Downloads maps based on filter ID
  • Updates Rust Wipe Bot config files with map seeds
  • Handles pagination automatically
  • Implements rate limiting to respect API constraints
  • Creates backups of existing map data
  • Stores maps data in JSON format
  • Preserves YAML formatting and comments

Prerequisites

  • Go 1.21 or higher
  • RustMaps API key
  • RustMaps filter ID

Installation

Pre-built binaries

Download the latest release for your platform from the Releases page.

Available platforms:

  • Windows (32/64-bit)
  • Linux (32/64-bit)
  • macOS (Intel/Apple Silicon)

Building from source

  1. Clone the repository:
git clone https://github.com/kWAYTV/rustmaps-downloader.git
cd rustmaps-downloader
  1. Make scripts executable (Linux only):
chmod +x scripts/*.sh
  1. Copy the example environment file and fill in your credentials:
cp .env.example .env
  1. Edit .env with your API credentials:
RUSTMAPS_API_KEY=your_api_key_here
RUSTMAPS_FILTER_ID=your_filter_id_here

Usage

Using Scripts

Windows

# Build the CLI
scripts\build.bat

# Show help
scripts\help.bat

Linux

# Build the CLI
./scripts/build.sh

# Show help
./scripts/help.sh

Using the Built CLI

After building with the build script:

  1. Get help and see available commands:
# Windows
rustmaps.exe --help

# Linux
./rustmaps --help
  1. Download maps using your filter:
# Windows
rustmaps.exe download

# Linux
./rustmaps download
  1. Update Rust Wipe Bot config with map seeds:
# Windows - Using relative paths
./rustmaps.exe update-config maps/rust_maps_[filter_id].json config.yml

# Windows - Using absolute paths (wrap in quotes if paths contain spaces)
./rustmaps.exe update-config "C:\Path\To\maps\rust_maps_[filter_id].json" "C:\Path\To\config.yml"

# Linux - Using relative paths
./rustmaps update-config maps/rust_maps_[filter_id].json config.yml

# Linux - Using absolute paths (wrap in quotes if paths contain spaces)
./rustmaps update-config "/path/to/maps/rust_maps_[filter_id].json" "/path/to/config.yml"

This command is designed to work with Rust Wipe Bot configuration files. It will update the world_seeds section of your bot's config with the seeds from your downloaded maps while preserving all other settings, comments, and formatting.

Note: When using absolute paths with spaces or special characters, make sure to wrap them in quotes.

  1. Get help for a specific command:
./rustmaps [command] --help

Output

The application creates a maps directory and saves the fetched data in JSON format. Files are named with an incrementing counter to avoid overwriting:

  • First run: maps/rust_maps_[filter_id].json
  • Second run: maps/rust_maps_[filter_id]_1.json
  • Third run: maps/rust_maps_[filter_id]_2.json And so on...

When using the update-config command, it will update the specified YAML config file while preserving all comments and formatting, only modifying the world_seeds section with the seeds from your maps JSON.

Project Structure

rustmaps-downloader/
β”œβ”€β”€ cmd/
β”‚   └── rustmaps/
β”‚       β”œβ”€β”€ main.go              # CLI entry point
β”‚       └── commands/
β”‚           β”œβ”€β”€ root.go          # Root command definition
β”‚           β”œβ”€β”€ download.go      # Download command implementation
β”‚           β”œβ”€β”€ update-config.go # Config update command implementation
β”‚           └── version.go       # Version command implementation
β”œβ”€β”€ .env.example                 # Example environment file
β”œβ”€β”€ .env                         # Your environment file (git-ignored)
└── README.md                    # This file

Adding New Commands

To add new functionality:

  1. Create a new file in cmd/rustmaps/commands/
  2. Define your command using cobra
  3. Register it in the init() function

Example structure for a new command:

package commands

import "github.com/spf13/cobra"

var newCmd = &cobra.Command{
    Use:   "commandname",
    Short: "Short description",
    Long:  `Longer description`,
    Run: func(cmd *cobra.Command, args []string) {
        // Command implementation
    },
}

func init() {
    RootCmd.AddCommand(newCmd)
}

Troubleshooting

  • If you get API errors, verify your credentials in the .env file
  • Make sure Go is properly installed and in your system PATH
  • For dependency issues, run go mod tidy

Shell Completion

The CLI supports shell autocompletion. To enable it:

Bash

# Linux
./rustmaps completion bash > /etc/bash_completion.d/rustmaps
# or locally
./rustmaps completion bash > ~/.rustmaps-completion.bash
source ~/.rustmaps-completion.bash

PowerShell

# Add to your PowerShell profile
rustmaps.exe completion powershell | Out-String | Invoke-Expression
# or temporarily
rustmaps.exe completion powershell > rustmaps.ps1
. .\rustmaps.ps1

Zsh

# Add to your zshrc
./rustmaps completion zsh > "${fpath[1]}/_rustmaps"
# or locally
./rustmaps completion zsh > ~/.rustmaps-completion.zsh
source ~/.rustmaps-completion.zsh

Fish

./rustmaps completion fish > ~/.config/fish/completions/rustmaps.fish

License

MIT

About

πŸ—ΊοΈ A Go-based CLI tool that bulk downloads Rust game maps data from RustMaps API with automatic pagination and rate limiting.

Topics

Resources

License

Stars

Watchers

Forks