/// Common command-line flags shared across commands
pub const CommonFlags = struct {
    json: bool = false,
    dry_run: bool = false,
    verbose: bool = false,
    force: bool = false,
    validate: bool = false,
};

/// Parse common flags from arguments
pub fn parseCommonFlags(args: []const []const u8, flags: *CommonFlags) struct { consumed: usize, had_help: bool } {
    var i: usize = 0;
    var had_help = false;
    while (i < args.len) : (i += 1) {
        const arg = args[i];
        if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) {
            had_help = true;
        } else if (std.mem.eql(u8, arg, "--json")) {
            flags.json = true;
        } else if (std.mem.eql(u8, arg, "--dry-run")) {
            flags.dry_run = true;
        } else if (std.mem.eql(u8, arg, "--verbose") or std.mem.eql(u8, arg, "-v")) {
            flags.verbose = true;
        } else if (std.mem.eql(u8, arg, "--force") or std.mem.eql(u8, arg, "-f")) {
            flags.force = true;
        } else if (std.mem.eql(u8, arg, "--validate")) {
            flags.validate = true;
        } else {
            break; // Stop at first non-flag argument
        }
    }
    return .{ .consumed = i, .had_help = had_help };
}

const std = @import("std");
