Skip to content

Custom Messages

updater.zig provides full control over what messages are displayed and how they appear to users.

Message Configuration

The MessageConfig struct controls all message-related options:

zig
const result = try updater.checkForUpdates(allocator, .{
    .provider = updater.providers.github,
    .owner = "muhammad-fiaz",
    .repo = "updater.zig",
    .current_version = "0.0.1",
    .messages = .{
        // Control what to show
        .show_update_available = true,
        .show_up_to_date = true,
        .show_skipped = false,
        .show_errors = true,
        .show_network_errors = false,

        // Custom messages
        .update_available_message = "🎉 A new version is available!",
        .up_to_date_message = "✅ You're running the latest version.",
        .error_message = "❌ Could not check for updates.",

        // Prefix and suffix
        .message_prefix = "┌─────────────────────────────────┐",
        .message_suffix = "└─────────────────────────────────┘",

        // Custom URLs and commands
        .custom_download_url = "https://example.com/releases",
        .update_command = "zig fetch --save <url>",

        // Silent mode
        .silent = false,
    },
});

Available Options

Display Control

OptionDefaultDescription
show_update_availabletrueShow message when update is available
show_up_to_datetrueShow message when on latest version
show_skippedfalseShow message when check is skipped
show_errorstrueShow error messages
show_network_errorsfalseShow detailed network errors
silentfalseSuppress all messages

Custom Messages

OptionDescription
update_available_messageMessage when update is available
up_to_date_messageMessage when on latest version
error_messageMessage when check fails
message_prefixPrefix/header for all messages
message_suffixSuffix/footer for all messages

URLs and Commands

OptionDescription
custom_download_urlOverride provider download URL
update_commandCommand to display for updating

Silent Mode

To suppress all messages:

zig
.messages = .{
    .silent = true,
}

Formatting Messages

Use the built-in formatter:

zig
const message = try updater.formatUpdateMessage(allocator, result, config);
defer allocator.free(message);
std.debug.print("{s}", .{message});

// Or use the convenience function:
updater.printUpdateMessage(result, config);

Error Message Control

Control how errors are displayed:

zig
.messages = .{
    .show_errors = true,
    .show_network_errors = false, // Hide network details
    .error_message = "Unable to check for updates. Will retry later.",
}

Released under the MIT License.